Manoj M J
Manoj M J

Reputation: 449

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!

Upvotes: 5

Views: 1945

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599630

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/$.

Upvotes: 7

Related Questions