user15272133
user15272133

Reputation:

Reverse for 'password_reset_complete' not found

I am Using PasswordResetView for reset password, but when I Enter new Password and submit the button. Django redirect to this page

ulrs.py

from django.urls import path
from Authentication import views
from django.contrib.auth import views as auth_view
from .forms import *

app_name = 'Authentication'

urlpatterns = [
    path('', views.loginpage, name='loginpage'),
    path('login', views.handlelogin, name='login'),
    path('logout', views.handlelogout, name='logout'),
    path('password_reset', views.password_reset, name='password_reset'),

    path('password_reset/done/',
         auth_view.PasswordResetDoneView.as_view(template_name='Authentication_template/password_reset_done.html'),
         name='password_reset_done'),

    path('reset/<uidb64>/<token>/',
         auth_view.PasswordResetConfirmView.as_view(template_name='Authentication_template/password_reset.html',
                                                    form_class=SetPasswordForm), name='password_reset_confirm'),

    path('password_reset_complete/', auth_view.PasswordResetCompleteView.as_view(
        template_name='Authentication_template/password_reset_complete.html'),
         name='password_reset_complete')
]

here I use custom view for sending email to user.

Upvotes: 0

Views: 612

Answers (2)

Abdul Aziz Barkat
Abdul Aziz Barkat

Reputation: 21787

You have set app_name = 'Authentication' meaning you have namespaced those urls. So you now need to refer to them as Authentication:password_reset_complete instead of password_reset_complete, etc. See URL namespaces (Django docs)

One solution would be to remove the line app_name = 'Authentication', if you wish to keep those lines you would need to set the success_url for the views yourself, you can pass it as a kwarg to as_view:

from django.urls import reverse_lazy


path('reset/<uidb64>/<token>/',
    auth_view.PasswordResetConfirmView.as_view(
        template_name='Authentication_template/password_reset.html',
        form_class=SetPasswordForm,
        success_url = reverse_lazy('Authentication:password_reset_complete')
    ), name='password_reset_confirm'
)

Upvotes: 3

Sollych
Sollych

Reputation: 429

It appears you are using the wrong path name for your password_reset_complete.

Instead of path('password_reset_complete/'...

Try with:

path('reset/done/', auth_view.PasswordResetCompleteView.as_view(
    template_name='Authentication_template/password_reset_complete.html'),
     name='password_reset_complete')

Upvotes: 0

Related Questions