Changes between Initial Version and Version 1 of Ticket #34003


Ignore:
Timestamp:
Sep 10, 2022, 11:22:19 AM (2 years ago)
Author:
Brylie Christopher Oxley
Comment:

I realized this issue affects all four views involved in the password reset flow.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34003

    • Property Summary PasswordResetView and PasswordResetConfirmView not discovering custom templatePasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, & PasswordResetCompleteView not discovering custom template
  • Ticket #34003 – Description

    initial v1  
    88),
    99path(
     10    "password_reset/done/",
     11    auth_views.PasswordResetDoneView.as_view(
     12        template_name="accounts/password_reset_done.html",
     13    ),
     14    name="password_reset_done",
     15),
     16path(
    1017    "reset/<uidb64>/<token>/",
    1118    auth_views.PasswordResetConfirmView.as_view(),
    1219    name="password_reset_confirm",
    1320),
     21path(
     22    "reset/done/",
     23    auth_views.PasswordResetCompleteView.as_view(),
     24    name="password_reset_complete",
     25),
    1426}}}
    1527
    16 The [https://docs.djangoproject.com/en/4.1/topics/auth/default/#django.contrib.auth.views.PasswordResetView PasswordResetView] and  [https://docs.djangoproject.com/en/4.1/topics/auth/default/#django.contrib.auth.views.PasswordResetView PasswordResetConfirmView] docs say it will look for a template called ''registration/password_reset_form.html'' and "registration/password_reset_confirm.html" respectively and render that if available. When I define a template with the same name and location, the custom template is not discovered by the PasswordResetView nor PasswordResetConfirmView. Instead, the default Django Admin templates are rendered. This is despite other built in views like LoginView being able to fine conventionally named templates in the ''same'' directory.
     28The [https://docs.djangoproject.com/en/4.1/topics/auth/default/#django.contrib.auth.views.PasswordResetView PasswordResetView], [https://docs.djangoproject.com/en/4.1/topics/auth/default/#django.contrib.auth.views.PasswordResetView PasswordResetDoneView], [https://docs.djangoproject.com/en/4.1/topics/auth/default/#django.contrib.auth.views.PasswordResetView PasswordResetConfirmView] and [https://docs.djangoproject.com/en/4.1/topics/auth/default/#django.contrib.auth.views.PasswordResetCompleteView PasswordResetCompleteView] docs say Django will look for templates called ''registration/*'' and render those if available.
    1729
    18 Of note, the two problematic views are both responsible for rendering and validating forms during the password reset flow.
     30When I define templates with the documented name and location, the custom templates are not discovered by Django. Instead, the default Django Admin templates are rendered. This is despite other built in views like ''LoginView'' being able to fine conventionally named templates in the ''same'' directory.
     31
     32Of note, the problematic views are all part of the password reset flow.
    1933
    2034In order to work around the issue, I have had to move the custom template to a different template path specified via the template_name argument to the PasswordResetView:
     
    2943),
    3044path(
     45    "password_reset/done/",
     46    auth_views.PasswordResetDoneView.as_view(),
     47    name="password_reset_done",
     48),
     49path(
    3150    "reset/<uidb64>/<token>/",
    3251    auth_views.PasswordResetConfirmView.as_view(
     
    3554    name="password_reset_confirm",
    3655),
     56path(
     57    "reset/done/",
     58    auth_views.PasswordResetCompleteView.as_view(
     59        template_name="accounts/password_reset_complete.html",
     60    ),
     61    name="password_reset_complete",
     62),
    3763}}}
    3864
Back to Top