Skip to content Skip to sidebar Skip to footer

Noreversematch At /user/password_reset/ Reverse For 'password_reset_done' Not Found

I'm trying to use the Django authentication system, but I'm getting the error: enter image description here 'user' is an app name. Project's urls.py: from django.conf.urls import

Solution 1:

I ran into this issue too. These posts are outdated, so I want to give a revised answer. Essentially the PasswordResetConfirmView has the property of success_url which can be set at urls.py.

So for example...

path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(
    template_name='password-reset-confirm.html', success_url=reverse_lazy(
        'user:password_reset_complete')),
     name="password_reset_confirm"),

The problem is the default behavior of the Password Reset Confirm. Specifically it sets the success_url = reverse_lazy('password_reset_complete'). Since your password_reset_complete view is in your "user" app, it can't find it. The default property is telling it to look at the rooturls.py when you need it to be looking at user/urls.py. Overriding the success_url will solve this problem.

Solution 2:

url(r'^password_reset/$', auth_views.password_reset, {
        'post_reset_redirect': '/user/password_reset/done/'
    }, 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, {
         'post_reset_redirect': '/user/reset/done/'
    }, name='password_reset_confirm'),
    url(r'^reset/done/$', auth_views.password_reset_complete,
        name='password_reset_complete'),

I set 'post_reset_redirect' in user/urls.py , and everything started to work properly. And after submitting email on reset page, nothing was displayed in console, because of this:

If the email address provided does not exist in the system, this view won’t send an email, but the user won’t receive any error message either. This prevents information leaking to potential attackers.

Django Docs

Solution 3:

In your user/urls.py, it seems that you have no url, named /user/password_reset/

if you want to use django.auth default password reset then use,

from django.contrib.auth.views import password_reset

urlpatterns = patterns('',
     (r'^/accounts/password/reset/$', password_reset,{'template_name': 'my_templates/password_reset.html'}, name='password_reset_done'),
     ...
)

Here you can change your template name.

Post a Comment for "Noreversematch At /user/password_reset/ Reverse For 'password_reset_done' Not Found"