Reverse for 'password_reset_complete' not found

1,740 views
Skip to first unread message

ah bor

unread,
Aug 20, 2017, 7:47:48 PM8/20/17
to django...@googlegroups.com

Hello friends,

I will appreciate it if you can help me resolve the following issue.

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':'some...@gmail.com',},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:

password_reset_complete.html
password_reset_email.html
password_reset_confirm.html
password_reset_form.html
password_reset_done.html
password_reset_subject.txt


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

Thanks for your help,


James Schneider

unread,
Aug 24, 2017, 4:11:51 AM8/24/17
to django...@googlegroups.com


On Aug 20, 2017 4:47 PM, "ah bor" <ahb...@outlook.com> wrote:

Hello friends,

I will appreciate it if you can help me resolve the following issue.

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':'some...@gmail.com',},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'},

I doubt this success_url will work given the names you show here.

<snip>


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

Thanks for your help,

Is this your main urls.py file? Can you post up the main one?

I would suspect the success_url issue I pointed out above, but the erroneous URL name contains underscores. I'm not sure if the built in view will fall back to the default name (which does contain underscores) if the given success_url didn't resolve. But even if that were the case, you have a view with the proper name.

I almost feel like these URL's are not being used at all. The error doesn't make sense given your listing of URL's.

-James
Reply all
Reply to author
Forward
0 new messages