Open
Description
I am trying to have a custom email template. When I use PasswordResetForm
, everything seems to work fine:
from django.contrib.auth.forms import PasswordResetForm
class CustomPasswordResetSerializer(PasswordResetSerializer):
password_reset_form_class = PasswordResetForm
def get_email_options(self):
return {
"subject_template_name": "account/email/password_reset_subject.txt",
"email_template_name": "account/email/password_reset_message.html",
"html_email_template_name": "account/email/password_reset_message.html",
"extra_email_context": {
"settings": settings,
}
}
I am using allauth
. In this case, in order to have the correct uid
and token
, I need to use AllAuthPasswordResetForm
.
from dj_rest_auth.forms import AllAuthPasswordResetForm
class CustomPasswordResetSerializer(PasswordResetSerializer):
password_reset_form_class = AllAuthPasswordResetForm
def get_email_options(self):
return {
"subject_template_name": "account/email/password_reset_subject.txt",
"email_template_name": "account/email/password_reset_message.html",
"html_email_template_name": "account/email/password_reset_message.html",
"extra_email_context": {
"settings": settings,
}
}
But then get_email_options
not working. It keeps sending the default template.
My settings look like this:
REST_AUTH = {
"USE_JWT": True,
"JWT_AUTH_HTTPONLY": False,
"JWT_AUTH_COOKIE": "authToken",
"JWT_AUTH_REFRESH_COOKIE": "refreshToken",
"JWT_TOKEN_CLAIMS_SERIALIZER":
"apps.authentication.serializers.CustomTokenObtainPairSerializer",
"REGISTER_SERIALIZER":
"apps.authentication.serializers.CustomRegisterSerializer",
"PASSWORD_RESET_SERIALIZER":
"apps.authentication.serializers.CustomPasswordResetSerializer",
}
Dependencies:
dj-rest-auth[with_social]==6.0.0
django-allauth==0.61.1
djangorestframework-simplejwt==5.2.2
djangorestframework==3.14.0
How to use my custom email template?
Metadata
Metadata
Assignees
Labels
No labels