Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: I want to recognize a hash url

I have a url like http://localhost/user/?hash={hash value generated}

i need to configure urls.py so that any url of this form is recognized and does not give an error.

I currently wrote urls.py as

url(r'^user/(?P<hash>\w+)/$', 'Myapp.views.createnewpass'),

and this is giving a 404 error for a valid hash.

How can I correct this error?

Thanks in advance!

like image 354
Manoj M J Avatar asked Apr 05 '13 07:04

Manoj M J


1 Answers

Well, it should be clear to you that the regex does not match the URL: it's looking for URLs in the form /user/hash/, whereas you have /user/?hash=hash.

In any case, query parameters (those after the ?) do not get processed by urls.py, they are passed in request.GET. So your URLconf should just be r'^user/$.

like image 156
Daniel Roseman Avatar answered Sep 20 '22 22:09

Daniel Roseman