P. Naoum
P. Naoum

Reputation: 477

Django rest-auth password reset not working

I'm using Django for building a RESTful API for a mobile app, I use django rest-auth library for authentication, but I get the following error when I try using password reset:

NoReverseMatch at /auth/password/reset/
Reverse for 'auth_password_reset_confirm' with arguments '(b'OQ', '4nx-
6653c24101b5443f726b')' and keyword arguments '{}' not found. 0 pattern(s) 
tried: []

Given this snippet from my url patterns

url(r'^', include('django.contrib.auth.urls')),
url(r'^auth/', include('rest_auth.urls')),
url(r'^auth/registration/', include('rest_auth.registration.urls')),

I tried some solutions mentioned here (as adding this first pattern in the snippet) but still having the same error.

Upvotes: 3

Views: 3871

Answers (3)

Umar Asghar
Umar Asghar

Reputation: 4034

This error means you have not defined any url with this name auth_password_reset_confirm so you need to make a url with this name auth_password_reset_confirm.

You need to customize the django rest-auth in such a way.

In rest-auth > urls.py

urlpatterns = [
    ....
    url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', PasswordResetConfirmView.as_view(),
    name='auth_password_reset_confirm'),
    ....
]

See in this case, you put the name as auth_password_reset_confirm. In my case, I got this error for this reverse url password_reset_confirm so I put that as a name in urls.

But in your case it would be auth_password_reset_confirm.

Upvotes: 0

David Sidarous
David Sidarous

Reputation: 1272

Try This : In Settings.py : Make sure 'app' is at the end of installed apps

then try again

Upvotes: 0

Gabriel Muj
Gabriel Muj

Reputation: 3805

You don't have that url defined, you can check the demo project from rest-auth library to see how it handles the urls (and related templates).

https://github.com/Tivix/django-rest-auth/blob/master/demo/demo/urls.py

Upvotes: 1

Related Questions