I'm trying to use django-rest-auth password reset feature but after a post request at /rest-auth/password/reset/
i get the error stated in the title (Traceback) and i don't understand why. I followed the installation procedure from the documentation page. My urls.py
is:
from django.urls import include, path
urlpatterns = [
path('users/', include('users.urls')),
path('rest-auth/', include('rest_auth.urls')),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
I also added the required apps in settings.py
In addition to login and logout views, django's auth app has views that can let users reset their password if they forget it. Let's go ahead and see how we can add this functionality into our app. 1) User clicks on "forgot password" link - This will take them to a page where they will be prompted to enter their email address.
Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name. Is it because my app name is houses?
DJANGO_REST_PASSWORDRESET_NO_INFORMATION_LEAKAGE - will cause a 200 to be returned on POST $ {API_URL}/reset_password/ even if the user doesn't exist in the databse (Default: False) DJANGO_REST_MULTITOKENAUTH_REQUIRE_USABLE_PASSWORD - allows password reset for a user that does not have a usable password (Default: True)
This library should be compatible with the latest Django and Django Rest Framework Versions. For reference, here is a matrix showing the guaranteed and tested compatibility. This package supports the DRF auto-generated documentation (via coreapi) as well as the DRF browsable API.
I solved by adding
from django.urls import include, path, re_path
from rest_auth.views import PasswordResetConfirmView
re_path(r'^rest-auth/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='password_reset_confirm'),
to urlpatterns in urls.py
. This way you will obtain a reset link in the mail like: ../password/reset/confirm/uid/token
. In order to complete the procedure you must send a POST request to ../password/reset/confirm/
with this body:
{
"new_password1": "",
"new_password2": "",
"uid": "",
"token": ""
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With