[Django] #28935: Template error raised in an {% extends %} child template shows incorrect source location on debug page

79 views
Skip to first unread message

Django

unread,
Dec 16, 2017, 7:06:02 PM12/16/17
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
-----------------------------------------+------------------------
Reporter: Matt Westcott | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 2.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
If an error occurs in the processing of a template tag on a template that
extends another via `{% extends %}`, the "Error during template rendering"
section of the debug page incorrectly shows an excerpt from the parent
template rather than the child.

To reproduce:

base.html:
{{{
{% block body %}{% endblock %}
}}}

home.html:
{{{
{% extends "base.html" %}

{% block body %}
{% include "does_not_exist" %}
{% endblock %}
}}}

views.py:
{{{
from django.shortcuts import render

def home(request):
return render(request, 'home.html')
}}}

The resulting error page displays:

{{{
Error during template rendering
In template
/Users/matthew/Development/tbx/wagtail/debug/brokendebug/core/templates/base.html,
error at line 0

does_not_exist
1 {% block body %}{% endblock %}
2
}}}

instead of the expected error output:
{{{
Error during template rendering
In template
/Users/matthew/Development/tbx/wagtail/debug/brokendebug/core/templates/home.html,
error at line 4

does_not_exist
1 {% extends "base.html" %}
2
3 {% block body %}
4 {% include "does_not_exist" %}
5 {% endblock %}
6
}}}

Bisecting shows that this bug was introduced in #27956
(e643ba8bcf0b1da517cbab689ac157ee031202a3), which was a fix for the
''opposite'' case: an error occurring on the parent template. (In the
above test case, moving the line `{% include "does_not_exist" %}` to
base.html turns it into a test case for #27956, and fails on pre-
e643ba8bcf0b1da517cbab689ac157ee031202a3 revisions as expected.)

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

Django

unread,
Dec 28, 2017, 11:07:46 AM12/28/17
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------

Reporter: Matt Westcott | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* cc: Preston Timmons (added)
* component: Uncategorized => Template system
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


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

Django

unread,
Jan 7, 2018, 2:05:25 PM1/7/18
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
-------------------------------------+-------------------------------------
Reporter: Matt Westcott | Owner: Alexander
| Vyushkov
Type: Bug | Status: assigned

Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Alexander Vyushkov):

* status: new => assigned
* owner: nobody => Alexander Vyushkov


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

Django

unread,
Feb 11, 2018, 8:39:12 PM2/11/18
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: (none)
Type: Bug | Status: new

Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Alexander Vyushkov):

* owner: Alexander Vyushkov => (none)
* status: assigned => new


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

Django

unread,
Apr 9, 2018, 3:15:07 PM4/9/18
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Collin Anderson):

* cc: Collin Anderson (added)


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

Django

unread,
Jul 5, 2018, 1:46:08 PM7/5/18
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Ankur Jain
Type: Bug | Status: assigned

Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Ankur Jain):

* owner: (none) => Ankur Jain


* status: new => assigned


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

Django

unread,
Jul 7, 2018, 1:10:47 AM7/7/18
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Ankur Jain
Type: Bug | Status: assigned
Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Ankur Jain):

When the parser runs then it appends all the child template nodes to the
parent template nodes and hence when template not found error comes then
it's reported from the parent html instead of the child html.

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

Django

unread,
Sep 6, 2018, 9:49:10 AM9/6/18
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Ankur Jain
Type: Bug | Status: assigned
Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Simon Charette):

#29740 was a duplicate.

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

Django

unread,
Apr 1, 2019, 6:27:41 PM4/1/19
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Ankur Jain
Type: Bug | Status: assigned
Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Michael F. Lamb):

Replying to [comment:6 Ankur Jain]:
Hi, I'm interested in working on this bug. Are you still working on it,
Ankur?

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

Django

unread,
May 28, 2019, 11:08:21 AM5/28/19
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Ankur Jain
Type: Bug | Status: assigned
Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by pascal chambon):

* cc: pascal chambon (added)


Comment:

Error confirmed on Django2.2.1, it makes the debug page much less helpful
in case of TemplateError, since most websites inherit their templates from
some kind of "base.html" skeleton.

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

Django

unread,
Jul 30, 2019, 4:26:17 AM7/30/19
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Ankur Jain
Type: Bug | Status: assigned
Component: Template system | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by Simone Lazzaris):

Bug still present in 2.2.3; if you (like me) use a tree-structured number
of small template files it is very VERY annoying as you have to guess
where the bug you're chasing is between the various parts.

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

Django

unread,
Jul 30, 2019, 4:27:12 AM7/30/19
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Ankur Jain
Type: Bug | Status: assigned
Component: Template system | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Simone Lazzaris):

* cc: Simone Lazzaris (added)
* version: 2.0 => 2.2


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:11>

Django

unread,
Jul 30, 2019, 4:37:12 AM7/30/19
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: master

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

* owner: Ankur Jain => (none)


* status: assigned => new

* version: 2.2 => master


Comment:

Simone, patch is welcome.

--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:12>

Django

unread,
Sep 3, 2019, 12:45:44 PM9/3/19
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Min ho Kim):

* cc: Min ho Kim (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:13>

Django

unread,
Sep 12, 2019, 3:46:13 PM9/12/19
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+--------------------------------------
Reporter: Matt Westcott | Owner: Min ho Kim
Type: Bug | Status: assigned

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Changes (by Min ho Kim):

* owner: (none) => Min ho Kim


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:14>

Django

unread,
Jan 10, 2020, 7:38:21 AM1/10/20
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Changes (by Min ho Kim):

* owner: Min ho Kim => (none)


* status: assigned => new


Comment:

I'm deassigning myself for now so someone else can have a go until I can
come back in the future.

--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:15>

Django

unread,
Feb 23, 2020, 1:54:33 AM2/23/20
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
-------------------------------------+-------------------------------------
Reporter: Matt Westcott | Owner: Ashutosh
| Sharma
Type: Bug | Status: assigned

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ashutosh Sharma):

* owner: (none) => Ashutosh Sharma


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:16>

Django

unread,
Feb 25, 2020, 12:53:42 AM2/25/20
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Ashutosh Sharma):

* owner: Ashutosh Sharma => (none)


* status: assigned => new


Comment:

I couldn't find a way to fix this bug. Deassigning so someone else can
have a try.

--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:17>

Django

unread,
Mar 3, 2020, 3:41:34 PM3/3/20
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: Zahid92
Type: Bug | Status: assigned

Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Zahid92):

* owner: (none) => Zahid92


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:18>

Django

unread,
Apr 20, 2020, 4:36:28 AM4/20/20
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
-------------------------------------+-------------------------------------
Reporter: Matt Westcott | Owner: Zahid
| Hussain Ansari

Type: Bug | Status: assigned
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by felixxm):

#31478 was a duplicate.

--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:19>

Django

unread,
May 2, 2021, 5:47:43 PM5/2/21
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------

Reporter: Matt Westcott | Owner: (none)
Type: Bug | Status: new
Component: Template system | Version: dev

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim Graham):

* owner: Zahid Hussain Ansari => (none)


* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:20>

Django

unread,
May 5, 2021, 6:22:03 PM5/5/21
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: cammil
Type: Bug | Status: assigned

Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by cammil):

* owner: (none) => cammil


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:21>

Django

unread,
May 5, 2021, 6:24:18 PM5/5/21
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: cammil
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by cammil):

Think I have an idea how to fix this. Going to do some more testing to
make sure.

--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:22>

Django

unread,
May 7, 2021, 5:01:34 PM5/7/21
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: cammil
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by cammil):

I've created a PR:
https://github.com/django/django/compare/main...cammil:ticket_27694

Does anyone have any comments or feedback?

--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:23>

Django

unread,
May 7, 2021, 5:06:11 PM5/7/21
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
---------------------------------+------------------------------------
Reporter: Matt Westcott | Owner: cammil
Type: Bug | Status: assigned
Component: Template system | Version: dev
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 cammil):

* cc: cammil (added)
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:24>

Django

unread,
Jul 2, 2021, 5:33:03 AM7/2/21
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
-------------------------------------+-------------------------------------

Reporter: Matt Westcott | Owner: cammil
Type: Bug | Status: assigned
Component: Template system | Version: dev
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 Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:25>

Django

unread,
Jul 2, 2021, 6:20:45 AM7/2/21
to django-...@googlegroups.com
#28935: Template error raised in an {% extends %} child template shows incorrect
source location on debug page
-------------------------------------+-------------------------------------
Reporter: Matt Westcott | Owner: cammil
Type: Bug | Status: closed

Component: Template system | Version: dev
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 Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"313c3d1aa14d80922003f841c257ec4e153f8653" 313c3d1]:
{{{
#!CommitTicketReference repository=""
revision="313c3d1aa14d80922003f841c257ec4e153f8653"
Fixed #28935 -- Fixed display of errors in extended blocks.

Get the template that caused the exception and get the
exception info from that template, using the node that
caused the exception.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28935#comment:26>

Reply all
Reply to author
Forward
0 new messages