I recently upgraded to Django 4.0 and upgraded django-allauth
with alongside django-rest-auth
.
When a user fills out the password reset form under http://localhost:8000/api/dj-rest-auth/password/reset/
they get a link in the console that goes to:
http://localhost:8000/users/reset/2n/bxggn2-05019c81f9d6dfda6a10b7cfec09e839/
The link provided gets me to this old form:
How can I get this message in the console to point to accounts/password/reset/key/1-set-password/
?
That form looks like this:
That’s where my allauth
form lives and I’m not fully sure if this is the correct approach.
Below is some of my settings and urls.
Any help is gladly appreciated.
Thanks!
settings.py
INSTALLED_APPS = [
# Local,
'api.apps.ApiConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.sessions',
'django.contrib.messages',
'whitenoise.runserver_nostatic',
'django.contrib.staticfiles',
'django.contrib.sites',
'users',
# 3rd Party
'rest_framework',
'rest_framework.authtoken',
'allauth',
'allauth.account',
'allauth.socialaccount',
'dj_rest_auth',
'dj_rest_auth.registration',
'corsheaders',
'drf_yasg',
]
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
]
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAdminUser',
'rest_framework.permissions.IsAuthenticated',
],
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
],
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema'
}
urls.py
from django.urls import path, include
from allauth.account.views import ConfirmEmailView, EmailVerificationSentView
urlpatterns = [
path('accounts/', include('allauth.urls')),
path('', include('users.urls')),
path('api/', include('api.urls')),
path('api-auth/', include('rest_framework.urls')),
path('api/dj-rest-auth/registration/account-confirm-email/<str:key>/',
ConfirmEmailView.as_view()), # Needs to be defined before the registration path
path('api/dj-rest-auth/', include('dj_rest_auth.urls')),
path('api/dj-rest-auth/registration/', include('dj_rest_auth.registration.urls')),
path('api/rest-auth/registration/account-confirm-email/',
EmailVerificationSentView.as_view(), name='account_email_verification_sent'),
path('', include('django.contrib.auth.urls')),
path('users/', include('users.urls')),
path('users/', include('django.contrib.auth.urls')),
]
So I figured it out!
Had to update my urls.py
to the following:
from dj_rest_auth.views import PasswordResetConfirmView
path('users/reset/<uidb64>/<token>/', PasswordResetConfirmView.as_view()),
This url now points to the django password reset confirm view in the django rest API which is fine to reset the password on the backend.
Thanks!