Opened 14 years ago
Closed 14 years ago
#18216 closed Uncategorized (invalid)
Problem run manage.py
| Reported by: | Chriskras | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.4 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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
Note:
See TracTickets
for help on using tickets.
TicketClosingReasons/UseSupportChannels