Royal Sigdel
Royal Sigdel

Reputation: 11

cannot reset password django 2.1

Cannot reset password django 2.1

TypeError: PasswordResetDoneView() received an invalid keyword 'success_url'. as_view only accepts arguments that are al
ready attributes of the class in dhango 2.1

while redirecting to the reset views it shows up this error. mu urls.py is: from django.urls import path,reverse_lazy from .import views from django.contrib.auth.views import LoginView,LogoutView,PasswordResetView,PasswordResetDoneView,PasswordResetConfirmView,PasswordResetCompleteView

app_name='account'
urlpatterns = [

   path('',views.home,name='home'),
   path('login/',LoginView.as_view(template_name='account/login.html'),name='login'),
   path('logout/',LogoutView.as_view(template_name='account/logout.html'),name='logout'),
   path('register',views.register),
   path('profile',views.view_profile,name='view_profile'),
   path('profile/edit',views.edit_profile,name='edit_profile'),
   path('change_password',views.change_password,name='change_password'),
   path('password_reset/', PasswordResetView.as_view(template_name='account/reset_password.html',email_template_name='account/reset_password_email.html',success_url = reverse_lazy('password_reset_done')), name='password_reset'),
   path('password_reset/done/',PasswordResetDoneView.as_view(template_name='account/reset_password_done.html',success_url = reverse_lazy('account:password_reset_complete')), name='password_reset_done'),
   path('password_reset/confirm/<uidb64>/<token>/',PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
   path('password_reset/complete/',PasswordResetCompleteView.as_view(), name='password_reset_complete'),
   ]

How to resolve it?

Upvotes: 1

Views: 696

Answers (1)

Muhammad Rehan
Muhammad Rehan

Reputation: 26

Instead of this:

path('password_reset/done/',PasswordResetDoneView.as_view(template_name='account/reset_password_done.html',success_url = reverse_lazy('account:password_reset_complete')), name='password_reset_done')

You Should:

Put success_url in PasswordResetConfirmView because that'll redirect to PasswordResetComplete, like so:

path('password_reset/confirm/<uidb64>/<token>/',PasswordResetConfirmView.as_view(success_url = reverse_lazy('account:password_reset_complete'), name='password_reset_confirm')

For more Information read the documentation: https://docs.djangoproject.com/en/2.2/topics/auth/default/

Upvotes: 1

Related Questions