0
votes

I ran this command:

python manage.py runserver 0.0.0.0:8000

get error:

Traceback (most recent call last):
  File "manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 399, in    execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
    commands = get_commands()
  File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 107, in get_commands
    apps = settings.INSTALLED_APPS
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 49, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'mysite2.settings.settings_custom' (Is it on sys.path? Is there an import error in the settings file?): No module named mysite2.settings.settings_custom

Here's my manage.py:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    sys.path.append('/home/ec2-user/mysite2/mysite2/settings/settings_custom')
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite2.settings.settings_custom")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

Here's the file locations:

mysite2

inside mysite2,

  • manage.py
  • mysite2 (A folder)

Inside mysite2,

  • urls.py
  • wsgi.py
  • settings (A folder)

Inside settings

  • __init__.py
  • __init__.pyc
  • settings_custom.py
  • settings_default.py

How should I import the path to sys.path? Very new to Django, thanks very much.

1
just give settings no need mysitesundar nataraj

1 Answers

0
votes

I think you missed the init.py in mysite2 inside folder.

Just follow this structure,

mysite2

inside mysite2,

manage.py
mysite2 (A folder)

Inside mysite2,

__init__.py --> my edit
urls.py
wsgi.py
settings (A folder)

Inside settings

__init__.py
settings_custom.py
settings_default.py