Django 2 NoReverseMatch (Default Django Reset Password View)

541 views
Skip to first unread message

Emprex KG

unread,
Sep 15, 2018, 7:58:49 AM9/15/18
to Django users
Hey Everyone,

I have been getting to grips wit Django over the last week no real issue :D

However today since adding namespaces to my apps, I have gotten this error

NoReverseMatch
       at
/account/reset_password/


 
Reverse for 'password_reset_done' not found. 'password_reset_done' is not a valid view function or pattern name.  
Request Method:POST
Request URL:http://127.0.0.1:8000/account/reset_password/
Django Version:2.1.1
Exception Type:NoReverseMatch
Exception Value:
Reverse for 'password_reset_done' not found. 'password_reset_done' is not a valid view function or pattern name.
Exception Location:C:\Users\gilbe\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 622
Python Executable:C:\Users\gilbe\AppData\Local\Programs\Python\Python37-32\python.exe
Python Version:3.7.0
Python Path:
['C:\\Users\\gilbe\\Desktop\\testapplication',
 
'C:\\Users\\gilbe\\Desktop\\testapplication',
 
'C:\\Users\\gilbe\\AppData\\Local\\Programs\\Python\\Python37-32\\python37.zip',
 
'C:\\Users\\gilbe\\AppData\\Local\\Programs\\Python\\Python37-32\\DLLs',
 
'C:\\Users\\gilbe\\AppData\\Local\\Programs\\Python\\Python37-32\\lib',
 
'C:\\Users\\gilbe\\AppData\\Local\\Programs\\Python\\Python37-32',
 
'C:\\Users\\gilbe\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages',
 
'C:\\Program Files\\JetBrains\\PyCharm '
 
'2018.2.3\\helpers\\pycharm_matplotlib_backend']
Server time:Sat, 15 Sep 2018 11:36:06 +0000

 
I know that I need to change the post_reset_redirect but not sure how to do it

current url.py
path('reset_password/', PasswordResetView.as_view(template_name='accounts/reset_password.html'),
     name='reset_password'),





Emprex KG

unread,
Sep 15, 2018, 8:15:59 AM9/15/18
to Django users
I found the solution

by adding success_url to the path

path('reset_password/', PasswordResetView.as_view(template_name='accounts/reset_password.html',
success_url='/account/reset_password/done'), name='reset_password'),

Jason

unread,
Sep 15, 2018, 8:19:34 AM9/15/18
to Django users
so, Django has a couple views for password resets.  First is the actual password reset page, which sends a POST request, then redirects to Done which is the template returned to the server.  What's happening here is Django can't find the URL name password_reset_done, and throws this error

If you're customizing password reset, I would suggest looking at https://wsvincent.com/django-user-authentication-tutorial-password-reset/

https://github.com/django-extensions/django-extensions has a great utility, show_urls, as a management command.  This shows all the URLs in your project, along with the view classes/functions mapped to them as well as the url namespaces.  I wonder if you've done somethign else that removed password_reset_done from the project?
Reply all
Reply to author
Forward
0 new messages