Django newbie deployment question - ImportError: Could not import settings 'settings'

天大地大妈咪最大 提交于 2019-12-03 06:21:13

Your apache configuration should look like this:

<Location "/mysite">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
    PythonOption django.root /mysite
    PythonPath "['/root/djangoprojects/', '/root/djangoprojects/mysite','/root/djangoprojects/mysite/polls', '/var/www'] + sys.path"
    PythonDebug On
</Location>

Note that the sole difference is the "mysite.settings". Don't forget to restart apache once the config has changed (apache2ctl restart). See http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ for more info.

Try changing to the following:

<Location "/mysite">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE mysite.settings
    PythonOption django.root /mysite
    PythonPath "['/root/djangoprojects', '/var/www'] + sys.path"
    PythonDebug On
</Location>

Use no "/" at the end of the PythonPath entries (that may be an issue, I had problems with that at least on Windows).

The entries '/root/djangoprojects/mysite','/root/djangoprojects/mysite/polls' are not needed since you will be referring to your modules by full name (i.e. mysite.sttings means the settings module inside the mysite package, which is the correct way to access it in the PythonPath /root/djangoprojects).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!