我尝试的网址:http://127.0.0.1:8000/manifest/archive/?page=1
。 的正则表达式:(django)url正则表达式不匹配
- (原来的我试过):(最简单的可能,只是为了尝试)
r'^archive/(?P<reverse>[n]{0,1})/?\?page=[0-9]+/?'
- (更简单的我也试过在Python控制台)
r'^archive/\?page=[0-9]+'
r'^archive/\?page=1'
(但我逃以正确的方式问号,不是吗?)
我尝试了所有这些正则表达式中的巨蟒控制台和他们的工作很好,所以我觉得这个问题是不是一个错误的正则表达式。
所以:为什么这不工作?
可选信息:
项目URL-conf的:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', RedirectView.as_view(url=reverse_lazy('manifest:index'))),
url(r'^manifest/', include('manifest.urls', namespace='manifest')),
]
注:该URL 127.0.0.1:8000/manifest/index
比赛,因为它应该,所以不能对万事发错了。
的网址追踪:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/manifest/archive/?page=1
Using the URLconf defined in asqiir005.urls, Django tried these URL patterns, in this order:
^admin/
^$
^manifest/ ^$ [name='index']
^manifest/ ^(?P<number>[0-9]+)$ [name='article']
^manifest/ ^archive/\?page=1
^manifest/ ^archive/(?P<reverse>[n]{0,1})/?\?page=[0-9]+/? [name='paged_archive']
^manifest/ ^archive/all/(?P<reverse>[n]{0,1})/?$ [name='whole_archive']
^media\/(?P<path>.*)$
The current URL, manifest/archive/, didn't match any of these.
我们真的需要处理查询参数在URL中?我认为我们不需要。 下面的url模式应该可以正常工作: url(r'^ archive /',view_to_handle), –