0

The url I try: http://127.0.0.1:8000/manifest/archive/?page=1. The regex pattern:

  1. (The original one I tried): r'^archive/(?P<reverse>[n]{0,1})/?\?page=[0-9]+/?'
  2. (An easier I also tried in the python console.) r'^archive/\?page=[0-9]+'
  3. (The easiest possible, just to try.) r'^archive/\?page=1' (But I escaped the question mark in the right way, don't I?)

I tried all of these regexes in the python console and they worked nice, so I think the problem isn't about a wrong regex.

So: why don't this work?


Optional information:

the projects 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')),
]

note: the url 127.0.0.1:8000/manifest/index matches as it should, so can't be about everything is made wrong.


The url traceback:

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.

1
  • Do we really need to handle query params in urls? I think we don't need to. The following url pattern should work fine : url(r'^archive/', view_to_handle), Commented Apr 17, 2017 at 12:24

2 Answers 2

1

This should be your file manifest.urls :

urlpatterns = [
    url(r'^archive/?$', view_to_handle),
]
Sign up to request clarification or add additional context in comments.

Comments

1

You can use request.GET.get('page', '') in your views.

Other options: https://stackoverflow.com/a/150518/3336408

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.