0

I am currently working on developing a password reset function for my project, and I want to use Sendgrid as my email backend and dj-rest-auth. Specifically, I am trying to override the email template with my custom template, but Django is still sending me the default email. I have no idea how to fix this issue and need your help.

here is the libraries

Django
django-sendgrid-v5
dj-rest-auth
django-allauth
dj-rest-auth

here is my code

SENDGRID_API_KEY = 'my api key here'
EMAIL_BACKEND = "sendgrid_backend.SendgridBackend"


REST_AUTH_SERIALIZERS = {
    'PASSWORD_RESET_SERIALIZER': 'accounts.serializers.CustomPasswordResetSerializer',
}
from dj_rest_auth.serializers import PasswordResetSerializer

class CustomPasswordResetSerializer(PasswordResetSerializer):
    def get_email_options(self):
        return {
            'domain_override': 'https://example.com',
            'html_email_template_name': '/template/password_reset.html'
        }
urlpatterns = [
                  path("password-reset/confirm/<uid>/<token>/",
                       TemplateView.as_view(template_name="password_reset_confirm.html"),
                       name='password_reset_confirm'),
                  path("dj-rest-auth/", include("dj_rest_auth.urls")),
              ]

I override get_email_options method and try to specify which email template should be used

danny
  • 3
  • 1

0 Answers0