在 Apache mod_python 上部署 django 应用程序
我已经在 django 中制作了一个名为“kazbah”的网站,并且正在尝试部署。
kazbah 站点的所有代码都在 /home/git/DjangoProjects/kazbah 中,我的 httpd.conf 看起来像:
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE kazbah.settings
PythonDebug On
PythonPath "['/home/git/DjangoProjects'] + sys.path"
</Location>
但我收到以下错误:
ImportError: Could not import settings 'kazbah.settings' (Is it on sys.path ?它有语法错误吗?):没有名为 kazbah.settings 的模块
知道为什么这个菜鸟失败了吗?
I've finished making a site in django called 'kazbah', and I'm trying to deploy.
All the code for the kazbah site is in /home/git/DjangoProjects/kazbah and my httpd.conf looks like:
<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE kazbah.settings
PythonDebug On
PythonPath "['/home/git/DjangoProjects'] + sys.path"
</Location>
I get the following error though:
ImportError: Could not import settings 'kazbah.settings' (Is it on sys.path? Does it have syntax errors?): No module named kazbah.settings
Any idea why this noob is failing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
对于位于
/var/www/bbb
(称为“bbb”)下的项目,我在配置文件中进行了以下设置:For a project resting under
/var/www/bbb
(called, "bbb"), I have the following set in the configuration file:我已经见过几次了。 每次都是因为我错误地设置了这一行:
尽管它看起来是正确的,但 Django(实际上是 python)正在查找与我想要的文件夹不同的文件夹。 尝试调整它,将其更改为:
另外,您可以在此处调整:
可能您需要将其设置为:
或类似的内容。 如果没有看到实际的文件夹设置,就很难准确地知道。 :)
I've seen this a few times. Every time, it's been because I incorrectly set this line:
Even though it looked right, Django (actually python) was looking one folder off from the one I intended. Try tweaking it, changing it to:
Also, you can tweak here:
It might be that you need to set it to:
or something similar. Without seeing your actual folder setup, it's hard to know exactly. :)
路易斯,你的配置看起来和我切换到 mod_wsgi 之前使用的配置一模一样,所以肯定还有其他问题。 也许您在 /home/git/DjangoProjects/kazbah 中缺少 __init__.py 文件?
Louis, your configuration looks exactly like ones I used before I switched to mod_wsgi, so there must be something else wrong. Maybe you are missing an __init__.py file in /home/git/DjangoProjects/kazbah?
我很确定你可以做 sys.path 的事情 - 它在 django 文档中。
我可能会查看 django 文档 http://docs.djangoproject.com/ en/dev/howto/deployment/modpython/ 因为我正在尝试另一个教程(我认为这有点过时) - http://www.jeffbaier.com/2007/07/26/installing-django-on-an-ubuntu-linux -服务器/
I'm pretty sure you can do the sys.path thing - it's in the django documentation.
I might go over the django doc http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ as I was trying another tutorial(which is a bit outdated I think) - http://www.jeffbaier.com/2007/07/26/installing-django-on-an-ubuntu-linux-server/
好的,也许您的设置文件中有语法错误。
试试这个:
如果有任何错误,这样做会给你一个更好的错误消息。
Ok, maybe you have a syntax error in your settings file.
Try this:
Doing it this way will give you a much better error message if there are any errors.