I am trying to develop an sample project in Django and getting errors when I run the syncdb command.
This is how my project structure looks like:
/Users/django_demo/godjango/bookings:
manage.py
registration/
forms.py
views.py
models.py
urls.py
bookings/
settings.py
urls.py
And my manage.py file is as follows:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bookings.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
And my PYTHONPATH and DJANGO_SETTINGS_MODULE are set as below
$echo $DJANGO_SETTINGS_MODULE
bookings.settings
$ echo $PYTHONPATH
/Users/django_demo/godjango/bookings
And my WSGI.py file looks like below:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bookings.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
When I run the python manage.py syncdb command, I am getting the following error.
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 8, in <module>
from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/sql.py", line 6, in <module>
from django.db import models
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/db/__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
self._setup()
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/Users/django_demo/godjango/lib/python2.7/site-packages/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 'bookings.settings' (Is it on sys.path?): No module named unipath
Could someone suggest what I am missing?
See Question&Answers more detail:
os