【发布时间】:2014-07-03 11:58:21
【问题描述】:
这是我的 urls.py 文件:
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'halo.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^halo/admin/', include(admin.site.urls)),
)
大多数时候,我可以访问 example.com/halo/admin。但有时,它会显示 404 错误:
Using the URLconf defined in halo.urls, Django tried these URL patterns, in this order:
$admin/
The current URL, halo/admin/, didn't match any of these.
这很奇怪,因为我的 urls.py 中没有'$admin/'。
【问题讨论】:
-
您应该记住,django/python 或任何类型的编程语言都不能改变或修改自己。问题在于您的代码。根据您的代码,您必须使用 xxx.com/halo/admin/ 访问管理站点,因此使用 xxx.com/halo/admin 在这里没有帮助。 Urlconfig 无法自行更改。
-
我知道。但是,如何解释错误页面显示的原因:$admin/ 当前的 URL,halo/admin/,与这些都不匹配。
-
请将您传递的网址复制粘贴到浏览器中。
标签: django admin django-urls