我需要在我的apache服务器上部署我的Django应用程序,我已将以下内容添加到我的httpd.conf中:
<Location "/dashboard/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "['/home/firas/project/trunk/dashboard/analytics','/home/firas/project/trunk/dashboard', '/home/firas/project/trunk'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE dashboard.settings
PythonOption django.root /dashboard
PythonDebug On
</Location>
请求我的应用时出现以下错误:
mportError: Could not import settings 'settings' (Is it on sys.path? Does it have syntax errors?): No module named settings
我的settings.py没有语法错误。
有任何线索吗?
答案 0 :(得分:1)
如果你想让apache看到dashboard.settings,那么PythonPath应该以“project / trunk”结尾。
您可以使用
PythonPath "['/home/firas/project/trunk'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE dashboard.settings
或
PythonPath "['/home/firas/project/trunk/dashboard/analytics','/home/firas/project/trunk/dashboard', '/home/firas/project/trunk'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE settings
第一个更好,IMO。
答案 1 :(得分:0)
不确定你是否还在寻找答案,但对我来说这是apache权限。
chmod o+x settings.py
修正了它。