#18216: Problem run manage.py
----------------------------------------------+--------------------
     Reporter:  Chriskras                     |      Owner:  nobody
         Type:  Uncategorized                 |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.4
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 I want the code below is run with python. I give the following command:
 python manage.py sql and then I get all errors. What is the solution?


 {{{
 #!/usr/bin/env python
 import os
 import sys
 sys.path.append('/home/test/')
 sys.path.append('/home/test/standAlone')
 #sys.path.append('/home/test/standAlone/myApp')
 #os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

 if __name__ == "__main__":
          os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name
 }}.settings")
          from django.core.management import execute_from_command_line
          execute_from_command_line(sys.argv)

 }}}

 ----

 Error:

 {{{
 Traceback (most recent call last):
   File "manage.py", line 12, in <module>
     execute_from_command_line(sys.argv)
   File "/home/test/django/core/management/__init__.py", line 443, in
 execute_from_command_line
     utility.execute()
   File "/home/test/django/core/management/__init__.py", line 382, in
 execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/home/test/django/core/management/__init__.py", line 261, in
 fetch_command
     klass = load_command_class(app_name, subcommand)
   File "/home/test/django/core/management/__init__.py", line 69, in
 load_command_class
     module = import_module('%s.management.commands.%s' % (app_name, name))
   File "/home/test/django/utils/importlib.py", line 35, in import_module
     __import__(name)
   File "/home/test/django/core/management/commands/sql.py", line 4, in
 <module>
     from django.core.management.sql import sql_create
   File "/home/test/django/core/management/sql.py", line 6, in <module>
     from django.db import models
   File "/home/test/django/db/__init__.py", line 11, in <module>
     if DEFAULT_DB_ALIAS not in settings.DATABASES:
   File "/home/test/django/utils/functional.py", line 184, in inner
     self._setup()
   File "/home/test/django/conf/__init__.py", line 42, in _setup
     self._wrapped = Settings(settings_module)
   File "/home/test/django/conf/__init__.py", line 95, in __init__
     raise ImportError("Could not import settings '%s' (Is it on
 sys.path?): %s" % (self.SETTINGS_MODULE, e))
 ImportError: Could not import settings '{{ project_name }}.settings' (Is
 it on sys.path?): No module named {{ project_name }}.settings
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18216>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to