[Django] #25697: Default error views shouldn't silence TemplateDoesNotExist errors if a custom template name was specified

28 views
Skip to first unread message

Django

unread,
Nov 7, 2015, 8:58:15 AM11/7/15
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
------------------------------------------------+------------------------
Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+------------------------
Default error views attempt to load a template from a default name and
fallback to a string value if a `TemplateDoesNotExist` error is raised in
the process.

This behavior should be altered to actually raise the error if a custom
`template_name` is specified.

The affected views are:

1. `django.views.defaults.page_not_found`
2. `django.views.defaults.server_error`
3. `django.views.defaults.bad_request`
4. `django.views.defaults.permission_denied`

Note that the views were identified during a preliminary search and it's
possible this pattern is used elsewhere in the Django code base.

We should consider deprecating this behavior instead of simply turning it
on since it's slightly backward incompatible.

Thanks to Raphael Michel at #DUTH for helping identifying this issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/25697>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 7, 2015, 8:59:07 AM11/7/15
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Description changed by charettes:

Old description:

> Default error views attempt to load a template from a default name and
> fallback to a string value if a `TemplateDoesNotExist` error is raised in
> the process.
>
> This behavior should be altered to actually raise the error if a custom
> `template_name` is specified.
>
> The affected views are:
>
> 1. `django.views.defaults.page_not_found`
> 2. `django.views.defaults.server_error`
> 3. `django.views.defaults.bad_request`
> 4. `django.views.defaults.permission_denied`
>
> Note that the views were identified during a preliminary search and it's
> possible this pattern is used elsewhere in the Django code base.
>
> We should consider deprecating this behavior instead of simply turning
> it on since it's slightly backward incompatible.
>
> Thanks to Raphael Michel at #DUTH for helping identifying this issue.

New description:

Default error views attempt to load a template from a default name and
fallback to a string value if a `TemplateDoesNotExist` error is raised in
the process.

This behavior should be altered to actually raise the error if a custom
`template_name` is specified.

The affected views are:

1. `django.views.defaults.page_not_found`
2. `django.views.defaults.server_error`
3. `django.views.defaults.bad_request`
4. `django.views.defaults.permission_denied`

Note that the views were identified during a preliminary search and it's
possible this pattern is used elsewhere in the Django code base.

We should consider deprecating this behavior instead of simply turning it
on since it's slightly backward incompatible.

Thanks to Raphael Michel at #DUTH for helping identifying this issue.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:1>

Django

unread,
Nov 7, 2015, 9:05:42 AM11/7/15
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------

Reporter: charettes | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Generic views | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by carljm):

Yes, I think we'd need a deprecation path here where initially we raise a
PendingDeprecationWarning on an explicitly-specified nonexistent template,
then a DeprecationWarning, and then finally switch to raising the
TemplateNotFound.

--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:2>

Django

unread,
Nov 7, 2015, 10:05:53 AM11/7/15
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------
Reporter: charettes | Owner: yakky
Type: Cleanup/optimization | Status: assigned

Component: Generic views | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by yakky):

* owner: nobody => yakky
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:3>

Django

unread,
Nov 7, 2015, 11:27:24 AM11/7/15
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------
Reporter: charettes | Owner: yakky
Type: Cleanup/optimization | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by yakky):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:4>

Django

unread,
Nov 12, 2015, 8:07:44 PM11/12/15
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------
Reporter: charettes | Owner: yakky
Type: Cleanup/optimization | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by timgraham):

I'm lukewarm on deprecations (since it adds a lot of overhead for us)
instead of making minor backwards incompatible changes in cases like this
where it seems to simply delay revealing probable errors in user code. A
similar case was `select_related()` field name validation where we made a
backwards-incompatible change -- Carl, I believe you said you thought that
should have gone through a deprecation. Just wanted to bring it up for
discussion so I can crystallize my thinking around changes like this.
Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:5>

Django

unread,
Jan 7, 2016, 11:51:42 AM1/7/16
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------
Reporter: charettes | Owner: yakky
Type: Cleanup/optimization | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1
* easy: 1 => 0


Comment:

No one indicated an opposition [https://groups.google.com/d/topic/django-
developers/Nl9tVI2ap3I/discussion on the mailing list] to skipping a
deprecation and making this a backwards incompatible change.

--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:6>

Django

unread,
Jan 7, 2016, 12:04:56 PM1/7/16
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------
Reporter: charettes | Owner: yakky
Type: Cleanup/optimization | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by yakky):

Ok, I'll change the PR to avoid the deprecation period and edit the
changelog the reflect this change

--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:7>

Django

unread,
Jan 11, 2016, 6:49:39 PM1/11/16
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
--------------------------------------+------------------------------------
Reporter: charettes | Owner: yakky
Type: Cleanup/optimization | Status: assigned
Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:8>

Django

unread,
Jan 13, 2016, 7:26:04 PM1/13/16
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: yakky
Type: | Status: assigned
Cleanup/optimization |

Component: Generic views | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:9>

Django

unread,
Jan 14, 2016, 7:06:49 AM1/14/16
to django-...@googlegroups.com
#25697: Default error views shouldn't silence TemplateDoesNotExist errors if a
custom template name was specified
-------------------------------------+-------------------------------------
Reporter: charettes | Owner: yakky
Type: | Status: closed
Cleanup/optimization |

Component: Generic views | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"21bf685f5e660a187fcac31e84d5cd89758aeb74" 21bf685]:
{{{
#!CommitTicketReference repository=""
revision="21bf685f5e660a187fcac31e84d5cd89758aeb74"
Fixed #25697 -- Made default error views error when passed a nonexistent
template_name.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25697#comment:10>

Reply all
Reply to author
Forward
0 new messages