user3195543
user3195543

Reputation: 41

Django: Reverse for 'password_reset_complete' not found

I am trying to use the Django built-in views for resetting passwords but get an error in the very end. I have done the following steps: 1. in URLs.py:

url(r'^password_reset/$', auth_views.password_reset,{'email_template_name':'registration/password_reset_email.html','subject_template_name':'registration/password_reset_subject.txt','post_reset_redirect':'main:password_reset_done','from_email':'[email protected]',},name='password_reset'),
url(r'^reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',auth_views.PasswordResetConfirmView.as_view(),{'success_url':'passwordresetcomplete'}, name='password_reset_confirm' ),
url(r'^password_reset/done/$', auth_views.password_reset_done, {'template_name': 'registration/password_reset_done.html'}, name='password_reset_done'),
url(r'^reset/confirm/done/$', auth_views.password_reset_complete, name='password_reset_complete'),

I also have added my custom html files in appname/templates/registration/ the html files are:

Now here is what happens: when I go to http://127.0.0.1:8000/password_reset/ it asks for an email address. after entering an email for a user it says we have sent you a link and I see the link in email. when I click on the link, a page opens and ask for a new password and a password confirmation. When I hit the submit button, I can see that the password is really changed but instead of being directed to an html page I get an error. Here it is

NoReverseMatch at /reset/confirm/MQ/set-password/
Reverse for 'password_reset_complete' not found. 'password_reset_complete' is not a valid view function or pattern name.
Request Method:     POST
Request URL:    http://127.0.0.1:8000/reset/confirm/MQ/set-password/
Django Version:     1.11.2
Exception Type:     NoReverseMatch
Exception Value:    
Reverse for 'password_reset_complete' not found. 'password_reset_complete' is not a valid view function or pattern name.
Python Version:     2.7.12

Upvotes: 4

Views: 1978

Answers (1)

rishabh singh
rishabh singh

Reputation: 165

The link where you are getting error it by default looks in your project urls.py not in apps:urls.py try to put it in project.urls.py and the run the code

Upvotes: 1

Related Questions