django 网站看不到 urls.py
我刚刚将我的网站移至实际的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会更担心它找不到媒体目录,那是纯粹的apache。如果等式的这一部分不起作用,那么其他一切都不起作用。使用 apache 的 httpd.conf 直到您可以首先正确浏览到媒体目录。
更新:
我复制了我的工作conf文件并替换了你的值。您的 django.root 可能需要为“”或根本不设置,因为我发现它不应该以
/
结尾:并确保apache 运行您的网站的用户的
.profile
具有: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/
:And make sure that the
.profile
of the user that apache runs your site as, has:首先,不要使用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.