Changes between Initial Version and Version 1 of Ticket #34003
- Timestamp:
- Sep 10, 2022, 11:22:19 AM (2 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #34003
- Property Summary PasswordResetView and PasswordResetConfirmView not discovering custom template → PasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, & PasswordResetCompleteView not discovering custom template
-
Ticket #34003 – Description
initial v1 8 8 ), 9 9 path( 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 ), 16 path( 10 17 "reset/<uidb64>/<token>/", 11 18 auth_views.PasswordResetConfirmView.as_view(), 12 19 name="password_reset_confirm", 13 20 ), 21 path( 22 "reset/done/", 23 auth_views.PasswordResetCompleteView.as_view(), 24 name="password_reset_complete", 25 ), 14 26 }}} 15 27 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.28 The [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. 17 29 18 Of note, the two problematic views are both responsible for rendering and validating forms during the password reset flow. 30 When 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 32 Of note, the problematic views are all part of the password reset flow. 19 33 20 34 In 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: … … 29 43 ), 30 44 path( 45 "password_reset/done/", 46 auth_views.PasswordResetDoneView.as_view(), 47 name="password_reset_done", 48 ), 49 path( 31 50 "reset/<uidb64>/<token>/", 32 51 auth_views.PasswordResetConfirmView.as_view( … … 35 54 name="password_reset_confirm", 36 55 ), 56 path( 57 "reset/done/", 58 auth_views.PasswordResetCompleteView.as_view( 59 template_name="accounts/password_reset_complete.html", 60 ), 61 name="password_reset_complete", 62 ), 37 63 }}} 38 64