7

I am trying to create a reset password functionality in my application and added the following lines in my urls.py.

urls.py

url(r'^resetpassword/passwordsent/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
    url(r'^resetpassword/$', 'django.contrib.auth.views.password_reset'),
    url(r'^reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),
    url(r'^reset/done/$', 'django.contrib.auth.views.password_reset_complete'),

But when I enter my email id on reset password, it is showing an error which I am not able to understand. Reverse for 'password_reset_confirm' with arguments '()' and keyword arguments 'I have gone through some of the suggestions but none are working. Could anyone any help me with this error?

See the below image:

enter image description here

I

Savad KP
  • 1,625
  • 3
  • 28
  • 40
python
  • 4,403
  • 13
  • 56
  • 103
  • 1
    Please describe the steps you took to trigger the error. – Burhan Khalid Oct 18 '15 at 07:07
  • Seems like I have resolved this `error` by updating this url `url(r'^reset/(?P[0-9A-Za-z]+)-(?P.+)/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),` – python Oct 18 '15 at 07:09
  • I just added a name to it but now it is showing connection refused :/ – python Oct 18 '15 at 07:10

3 Answers3

9

Django needs to know how to resolve the URL from the name used in the url template tag. You should add the name to this line:

 url(r'^reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm'),

So it becomes:

 url(r'^reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),

See more about reverse resolution here:

https://docs.djangoproject.com/en/1.8/topics/http/urls/#reverse-resolution-of-urls

Will Hogan
  • 909
  • 4
  • 9
1

<uidb64>/<token>/ add "//" to your url and it should work

  • You need to add password_reset_confirm url into your urls.py (at the top of any other included urls). Please check the urls.py module inside demo app example for more details. – Aleem Nov 29 '22 at 10:59
0

Use the following to fix the error. Your regex is too strict, it's only allowing up to 20 characters. Refer to the following link for more information https://code.djangoproject.com/ticket/31913.

I changed the url to the below and it worked path(r'reset/<uidb64>/<token>/',

Nicolas
  • 156
  • 2
  • 2