我跑了这个命令:
python manage.py runserver 0.0.0.0:8000
得到错误:
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
这是我的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)
这是文件位置:
mysite2
在mysite2里面,
在mysite2里面,
内部设置
我应该如何导入sys.path的路径?对Django来说很新,非常感谢。
答案 0 :(得分:0)
我想你错过了mysite2里面文件夹中的 init .py。
按照这种结构,
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