Reputation: 1835
I have just learned from this tutorial to reset password in django. But I am not able to resolve the the
error:NoReverseMatch at /password_reset/done
from django.contrib.auth import views as auth_views
urlpatterns = [
url(r'^password_reset/$', auth_views.password_reset, name='password_reset'),
url(r'^password_reset/done/$', auth_views.password_reset_done, name='password_reset_done'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', auth_views.password_reset_confirm,
name='password_reset_confirm'),
url(r'^reset/done/$', auth_views.password_reset_complete, name='password_reset_complete'),
]
Upvotes: 0
Views: 1187
Reputation: 308769
Your password_reset_done.html
template is incorrect. It includes the following url tag which is causing the error.
{% url 'password_reset_confirm' uidb64=uid token=token %}
However that url belongs in the password_reset_email.html
template which is rendered and emailed to the user.
The password_reset_done.html
template should tell the user that the password has been reset and to check their email. The tutorial you linked to shows a valid template, you have copied it incorrectly.
Upvotes: 1
Reputation: 291
The main part of the traceback is:
Reverse for 'password_reset_confirm' with keyword arguments
'{u'uidb64': '', u'token': ''}' not found. 1 pattern(s) tried:
['reset/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$']
Empty strings don't match regular expressions it the url. You have to call reverse()
with proper uidb64
and token
. Do you pass them into your template context?
Upvotes: 1