django-rest-auth icon indicating copy to clipboard operation
django-rest-auth copied to clipboard

NoReverseMatch: Reverse for 'account_reset_password_from_key' not found. 'account_reset_password_from_key' is not a valid view function or pattern name.

Open 5parkp1ug opened this issue 7 years ago • 6 comments

I have been trying to setup password reset functionality in DRF using django-rest-auth. Earlier I was getting error TemplateDoesNotExist:registration/password_reset_email.html which I resolved by adding the following code code

serializer.py -

from rest_auth.serializers import PasswordResetSerializer
from allauth.account.forms import ResetPasswordForm  

class PasswordSerializer(PasswordResetSerializer):
    password_reset_form_class = ResetPasswordForm

settings.py -

REST_AUTH_SERIALIZERS = {
    'PASSWORD_RESET_SERIALIZER': 'api.serializers.PasswordSerializer',
}

However, Now I am getting into another issue - "NoReverseMatch: Reverse for 'account_reset_password_from_key' not found. 'account_reset_password_from_key' is not a valid view function or pattern name.". And haven't found any solution or workaround for this.

Any help would be appreciated.

5parkp1ug avatar Dec 21 '17 18:12 5parkp1ug

'account_reset_password_from_key' is a url name included in 'django-allauth' framework. Django-rest-auth uses allauth to send reset emails. SO you need to install django-allauth and add its urls.

PixelDust22 avatar Jan 12 '18 17:01 PixelDust22

I am too having this problem. NoReverseMatch at /rest-auth/password/reset/ Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name. I have installed django-allauth also.

prem2282 avatar Jul 14 '18 14:07 prem2282

Have a look at https://stackoverflow.com/questions/28418233/noreversematch-at-rest-auth-password-reset

KabzM avatar Jul 19 '18 12:07 KabzM

I also encountered the problem "Reverse for 'account_reset_password_from_key' not found. " I fixed the problem by adding allauth urls to urlpatterns:

urls.py
urlpatterns = [
  ...
  path('accounts/', include('allauth.urls')),
}

yybot1 avatar Aug 29 '18 13:08 yybot1

To anyone still encountering this issue after trying the above solutions, check number 2 out from the FAQ:

I get an error: Reverse for ‘password_reset_confirm’ not found. 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.

Here's the line in the demo that it's referring to: https://github.com/Tivix/django-rest-auth/blob/master/demo/demo/urls.py#L34

jmoujaes avatar Dec 20 '19 04:12 jmoujaes

I also was having this problem, and found this github issue it said we need to add

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

https://stackoverflow.com/questions/28418233/noreversematch-at-rest-auth-password-reset/29505964#29505964

aleemnazer avatar Nov 30 '20 16:11 aleemnazer