#34003: PasswordResetView, PasswordResetDoneView, PasswordResetConfirmView, &
PasswordResetCompleteView not discovering custom template
-------------------------------------+-------------------------------------
Reporter: Brylie Christopher | Owner: nobody
Oxley |
Type: Uncategorized | Status: new
Component: contrib.auth | Version: 4.1
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Old description:
> While defining URLs for a user password reset flow, I am using standard
> Django views such as PasswordResetView.
>
> {{{#!python
> path(
> "password_reset/",
> django.contrib.auth.views.PasswordResetView.as_view(),
> name="password_reset",
> ),
> path(
> "password_reset/done/",
> auth_views.PasswordResetDoneView.as_view(
> template_name="accounts/password_reset_done.html",
> ),
> name="password_reset_done",
> ),
> path(
> "reset/<uidb64>/<token>/",
> auth_views.PasswordResetConfirmView.as_view(),
> name="password_reset_confirm",
> ),
> path(
> "reset/done/",
> auth_views.PasswordResetCompleteView.as_view(),
> name="password_reset_complete",
> ),
> }}}
>
> 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.
>
> 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.
>
> Of note, the problematic views are all part of the password reset flow.
>
> 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:
>
> {{{#!python
> path(
> "password_reset/",
> django.contrib.auth.views.PasswordResetView.as_view(
> template_name="accounts/password_reset_form.html",
> ),
> name="password_reset",
> ),
> path(
> "password_reset/done/",
> auth_views.PasswordResetDoneView.as_view(),
> name="password_reset_done",
> ),
> path(
> "reset/<uidb64>/<token>/",
> auth_views.PasswordResetConfirmView.as_view(
> template_name="accounts/password_reset_confirm.html",
> ),
> name="password_reset_confirm",
> ),
> path(
> "reset/done/",
> auth_views.PasswordResetCompleteView.as_view(
> template_name="accounts/password_reset_complete.html",
> ),
> name="password_reset_complete",
> ),
> }}}
>
> In honesty, it is very possible that I have made a typo in the file name,
> but I have tried multiple times with the same result.
New description:
While defining URLs for a user password reset flow, I am using standard
Django views such as PasswordResetView.
{{{#!python
path(
"password_reset/",
django.contrib.auth.views.PasswordResetView.as_view(),
name="password_reset",
),
path(
"password_reset/done/",
auth_views.PasswordResetDoneView.as_view(),
name="password_reset_done",
),
path(
"reset/<uidb64>/<token>/",
auth_views.PasswordResetConfirmView.as_view(),
name="password_reset_confirm",
),
path(
"reset/done/",
auth_views.PasswordResetCompleteView.as_view(),
name="password_reset_complete",
),
}}}
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.
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.
Of note, the problematic views are all part of the password reset flow.
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:
{{{#!python
path(
"password_reset/",
django.contrib.auth.views.PasswordResetView.as_view(
template_name="accounts/password_reset_form.html",
),
name="password_reset",
),
path(
"password_reset/done/",
auth_views.PasswordResetDoneView.as_view(),
name="password_reset_done",
),
path(
"reset/<uidb64>/<token>/",
auth_views.PasswordResetConfirmView.as_view(
template_name="accounts/password_reset_confirm.html",
),
name="password_reset_confirm",
),
path(
"reset/done/",
auth_views.PasswordResetCompleteView.as_view(
template_name="accounts/password_reset_complete.html",
),
name="password_reset_complete",
),
}}}
In honesty, it is very possible that I have made a typo in the file name,
but I have tried multiple times with the same result.
--
Comment (by Brylie Christopher Oxley):
Fix typo
--
Ticket URL: <https://code.djangoproject.com/ticket/34003#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018328360c30-8e349ca3-9b3e-46b4-9da3-f265e4a9d3e2-000000%40eu-central-1.amazonses.com.