Django: I want to recognize the hash address

I have a url   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 have currently written urls.py as

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

and this gives a 404 error for a valid hash.

How can I fix this error?

Thanks in advance!

+5
source share
1 answer

Well, it should be clear to you that the regex doesn't match the url: it searches for urls of the form / user / hash /, while you have / user /? hash = hash.

In any case, the request parameters (after <?) Are not processed by urls.py, they are passed to request.GET. So your urlconf should be r'^user/$.

+7
source

All Articles