django 网站看不到 urls.py

发布于 2024-09-10 09:16:59 字数 388 浏览 8 评论 0原文

我刚刚将我的网站移至实际的 apache 服务器(之前在本地开发),并且该网站似乎找不到 urls.py 文件。基本上发生的情况是主页正常工作,考虑到如果我访问任何网址,例如 website/about/,我会收到带有文本 {'path': u'about/' 的 404 错误,这本身就很奇怪}

我尝试将 ROOT_URLCONF 设置为 mysite.urls 并且只是 url,如果我移动 urls.py 它将继续以相同的方式运行。

我不知道它是否相关,但我似乎也无法访问我的网站媒体文件夹,似乎服务器仍在其旧路径中读取它,但 settings.py 文件是正确的。 (尝试重新启动apache,重新启动服务器等..)

I just moved my site to an actual apache server (was developing locally before) and the site can't seem to find the urls.py file. basically what happens is that the homepage works, which is weird in itself considering that if i go to any url, e.g. website/about/, i will get a 404 error with text {'path': u'about/'}.

I tried ROOT_URLCONF set to mysite.urls and just urls, and if i move the urls.py it will continue to behave the same way.

I don't know if its related but I also can't seem to access my site media folder, it seems as though the server is still reading it in its old path, but the settings.py file is correct. (tried restarting apache, rebooting server, etc..)

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

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

发布评论

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

评论(2

浮生面具三千个 2024-09-17 09:16:59

我会更担心它找不到媒体目录,那是纯粹的apache。如果等式的这一部分不起作用,那么其他一切都不起作用。使用 apache 的 httpd.conf 直到您可以首先正确浏览到媒体目录。

更新:

我复制了我的工作conf文件并替换了你的值。您的 django.root 可能需要为“”或根本不设置,因为我发现它不应该以 / 结尾:

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

并确保apache 运行您的网站的用户的 .profile 具有:

export DJANGO_SETTINGS_MODULE='fikdusite.settings'
export PYTHONPATH=$PYTHONPATH:/django_apps:/django_apps/fikdusite

I would be more worried about it not finding the media directory, that's pure apache. If that part of the equation isn't working, nothing else will. Work with apache's httpd.conf until you can browse to the media directory correctly first.

Update:

I copied in my working conf file and substituted your values. Your django.root might need to be "" or not set at all, as I've found that it shouldn't end with a /:

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

And make sure that the .profile of the user that apache runs your site as, has:

export DJANGO_SETTINGS_MODULE='fikdusite.settings'
export PYTHONPATH=$PYTHONPATH:/django_apps:/django_apps/fikdusite
穿越时光隧道 2024-09-17 09:16:59

首先,不要使用mod_python,使用mod_wsgi。

其次,不要忘记每次在 Django 中进行代码更改时都需要重新启动 Apache。

First, don't use mod_python, use mod_wsgi.

Secondly, don't forget that you need to restart Apache every time you make a code change in Django.

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