Tivix / django-rest-auth

This app makes it extremely easy to build Django powered SPA's (Single Page App) or Mobile apps exposing all registration and authentication related functionality as CBV's (Class Base View) and REST (JSON)
www.tivix.com
MIT License
2.41k stars 660 forks source link

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

Open 5parkp1ug opened 6 years ago

5parkp1ug commented 6 years ago

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.

Neo-Zhixing commented 6 years ago

'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.

prem2282 commented 6 years ago

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.

KabzM commented 6 years ago

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

yybot1 commented 6 years ago

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')),
}
jmoujaes commented 4 years ago

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

aleemnazer commented 3 years ago

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