How to send html-styled password reset email with django

Viewed 24

I created an html-styled version of a password reset email to be set with django located at 'registration/html_password_reset_email.html'. From other stackoverflows, I learned I needed to add the html_email_template_name parameter for the html version of the email to be sent. However, even with the below code, it is just the text version of the file that is being sent ('registration/password_reset_email.html'). Hints on what I'm doing wrong?

from django.contrib import admin
from django.urls import include, path
from django.contrib.auth import views as auth_views
from django.views.generic.base import RedirectView
from django.urls import reverse

from . import views

urlpatterns = [
    path('', views.homeview, name="homeview"),
    path('dashboard/', include('dashboard.urls')),
    path('admin/', admin.site.urls),
    path('accounts/', include('django.contrib.auth.urls')),
    path("register/", views.register_request, name="register"),

    path('reset_password/', auth_views.PasswordResetView.as_view(
            template_name='registration/password_reset_form.html',
            html_email_template_name='registration/html_password_reset_email.html',
            email_template_name='registration/password_reset_email.html',  
        ), name="reset_password"), # Submit email form
    path('reset_password_sent/', auth_views.PasswordResetDoneView.as_view(), name="password_reset_done"), # Email sent success message
    path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name="password_reset_confirm"), # Link to password reset form in email
    path('reset_password_complete/', auth_views.PasswordResetCompleteView.as_view(), name="password_reset_complete"), # Password successfully changed message
]
0 Answers
Related