[Fixed]-NoReverseMatch on password_Reset_confirm

5👍

When using the url template tag, you need to specify the view and not the url itself. Since you are using 'django.contrib.auth.views.password_reset_confirm' in your URLConf you should use it like this:

{% url 'django.contrib.auth.views.password_reset_confirm' ... %}

More on the url template tag on Django’s Built-in template tags and filters documentation.

👤César

12👍

To pass a url to the url template tag, you can specify a name to the url in the urls.py

url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', 
views.password_reset_confirm, name='password_reset_confirm'),

and then you can use the tag with the url name

{% url 'password_reset_confirm' uidb64=uid token=token %}

1👍

Be sure to have this in your urls.py:

urlpatterns = [
    url('^', include('django.contrib.auth.urls'))
]

See https://docs.djangoproject.com/en/1.8/topics/auth/default/#django.contrib.auth.views.password_reset
Section: Authentication views

👤Davy

0👍

It might be a built-in view, but you still need a URL for it. You should define one in urls.py and link it up to the password_reset_confirm view.

0👍

Just copy this URL to your main urls.py file, so that it recognizes the URL name

url(r’^reset/(?P[0-9A-Za-z_-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$’,
‘django.contrib.auth.views.password_reset_confirm’,
name=’password_reset_confirm’),

👤K2A

Leave a comment