Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse Not Found Error

If I have a URL Like this:

url(r'^reset/(?P<uid>\w+)/(?P<token>\w+)/$', 'django.contrib.auth.views.password_reset_confirm', name="reset_password")

and a URL tag like this:

{% url 'reset_password' uid=uid token=token %}

Why do I get this error when I try to render the page in which the tag is contained:

Reverse for 'reset_password' with arguments '()' and keyword arguments not found 

The both the uid and token are valid strings.

like image 522
user1427661 Avatar asked Dec 19 '13 20:12

user1427661


People also ask

What does no reverse match mean?

The NoReverseMatch error is saying that Django cannot find a matching url pattern for the url you've provided in any of your installed app's urls. The NoReverseMatch exception is raised by django. core. urlresolvers when a matching URL in your URLconf cannot be identified based on the parameters supplied.

Where is reverse in Django?

the reverse function allows to retrieve url details from url's.py file through the name value provided there. This is the major use of reverse function in Django. The redirect variable is the variable here which will have the reversed value. So the reversed url value will be placed here.

How do I reverse in Django?

reverse() If you need to use something similar to the url template tag in your code, Django provides the following function: reverse (viewname, urlconf=None, args=None, kwargs=None, current_app=None)


1 Answers

I would say that your uid or your token has a non alphanumerical char like "-" or "." So I would try to change the urls.py to:

url(r'^reset/(?P<uid>.+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', name="reset_password")

I don't like using the . in regex but If you have not oteher choices...

like image 102
Viroide Avatar answered Sep 24 '22 12:09

Viroide