#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.

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.5277acf56ee8816af6ed34ed990a8279%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to