[Answered ]-How to send html-styled password reset email with django

1👍

You named your URL reset_password, while the name used by Django is password_reset. You have to use the same name, as it will be called by Django with reverse('reset_password'):

urlpatterns = [
    ...,
    path('accounts/', include('django.contrib.auth.urls')),
    ...,
    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="password_reset"), # <-
    ...,
]

Also, beware to keep this URL pattern after path('accounts/', include('django.contrib.auth.urls')), as the URL name will clash and the last one has the precedence.

When naming URL patterns, choose names that are unlikely to clash with other applications’ choice of names. If you call your URL pattern comment and another application does the same thing, the URL that reverse() finds depends on whichever pattern is last in your project’s urlpatterns list.

Leave a comment