Django URLconf自身发生了奇怪的变化

Django URLconf自身发生了奇怪的变化,django,admin,django-urls,Django,Admin,Django Urls,这是我的URL.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/adm

这是我的URL.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.

这很奇怪,因为我的url.py中没有“$admin/”。

有一个变化,您在浏览器中点击了错误的url

例如:


在这里,传入//url可能会产生与您所面临的问题相同的问题

您应该记住,django/python或任何类型的编程语言都不能更改或修改自身。问题在于你的代码。根据您的代码,您必须使用xxx.com/halo/admin/访问管理站点,因此使用xxx.com/halo/admin在这里没有帮助。Urlconfig无法更改自身。我知道。但是,如何解释错误页面显示的原因:$admin/当前URL halo/admin/,与其中任何一个都不匹配。请将传递到浏览器中的粘贴URL复制。
http://example.com//halo/admin/