'PasswordResetDoneView not using custom template in Django

PasswordResetDoneView.as_view is not loading custom template I'm using Django 2.2 version

I have created a custom template and add the path to accounts app url

url(r'^reset_password/done/$',PasswordResetDoneView.as_view(template_name='accounts/my_password_reset_done.html'),name='my_password_reset_done'),

My Template

{% extends 'base.html' %}

{% block body %}
<div class="container">
    <h1>Password Reset Done</h1>
    <p>
        We've emailed you instructions for setting your password if an account exists with the email you entered. You should receive them shortly.
        If you don't receive an email, please make sure you've entered the address you registered with, and check your spam folder.
    </p>

</div>
{% endblock %}

The issue

if I have -

path('', include('django.contrib.auth.urls')),

in my main URL then it is loading default Django template. if I removed that I'm getting the error that path doesn't exist and I'm trying to override the Django template with my own template but it is not loading.



Solution 1:[1]

I know this is late, but for future visitors, here's the solution. Change the URLs to below ones. (make sure you add your own template path)

The reason for this issue is because of the incorrect path mentioned. You can refer all the paths in the official documentation here.

    path('reset_password/',
     auth_views.PasswordResetView.as_view(template_name="pwd_reset/password_reset.html"),
     name="reset_password"),

    path('reset/<uidb64>/<token>/',
     auth_views.PasswordResetConfirmView.as_view(template_name="pwd_reset/password_reset_form.html"), 
     name="password_reset_confirm"),


    path('password_reset/done/', 
        auth_views.PasswordResetDoneView.as_view(template_name="pwd_reset/password_reset_sent.html"), 
        name="password_reset_done"),

    path('reset/done/', 
        auth_views.PasswordResetCompleteView.as_view(template_name="pwd_reset/password_reset_done.html"), 
        name="password_reset_complete"),

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fortyseven