Thursday, August 24, 2017

Re: Reverse for 'password_reset_complete' not found



On Aug 20, 2017 4:47 PM, "ah bor" <ahbor2@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':'something@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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWV%2BMpWGPBkpqz8yDkb5pB-gx%3DxuCm9GP5%2BOyr-1DwLPQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment