我尝试的网址:http://127.0.0.1:8000/manifest/archive/?page=1
。
正则表达式模式:
r'^archive/(?P<reverse>[n]{0,1})/?\?page=[0-9]+/?'
r'^archive/\?page=[0-9]+'
r'^archive/\?page=1'
(但我以正确的方式逃过了问号,不是吗?)我在python控制台中尝试了所有这些正则表达式并且它们工作得很好,所以我认为问题不在于错误的正则表达式。
所以:为什么不做这项工作?
可选信息:
项目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')),
]
注意:网址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.
答案 0 :(得分:1)
您可以在视图中使用request.GET.get(&#39; page&#39;,&#39;&#39;)。
答案 1 :(得分:1)
这应该是您的文件 manifest.urls :
urlpatterns = [
url(r'^archive/?$', view_to_handle),
]