mod_python 无法看到我的 Django 项目设置文件

发布于 2024-09-04 13:05:32 字数 699 浏览 9 评论 0原文

我需要在我的 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 没有语法错误。

有什么线索吗?

I need to deploy my Django application on my apache server, I've added the following to my 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>

I am getting the following error when requesting my app:

mportError: Could not import settings 'settings' (Is it on sys.path? Does it have syntax errors?): No module named settings

My settings.py has no syntax errors.

Any clue ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

峩卟喜欢 2024-09-11 13:05:32

如果你想让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。

if you want apache to see dashboard.settings, the PythonPath should end at "project/trunk".

You can use either

PythonPath "['/home/firas/project/trunk'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE dashboard.settings

or

PythonPath "['/home/firas/project/trunk/dashboard/analytics','/home/firas/project/trunk/dashboard', '/home/firas/project/trunk'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE settings

The first one is better, IMO.

小鸟爱天空丶 2024-09-11 13:05:32

不确定您是否仍在寻找答案,但对我来说这是 apache 权限。

chmod o+x settings.py 

修好了。

Not sure if you're still looking for an answer, but for me it was apache permissions.

chmod o+x settings.py 

Fixed it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文