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.
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.
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.
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)
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With