﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
27584	Template error raised in a parent template shows incorrect source location on debug page	Bob	nobody	"When an error is raised from a template the django debug page attempts to show the location in the template where the error occurred.  When this error occurs in a tag located on a parent template the debug page incorrectly shows the source from the child template instead of the parent.

Using a simple instance of template inheritance:

base.html
{{{
{% load app_tags %}
<!DOCTYPE HTML>
<html>
<head>
    <title>basic</title>

	{% magic %}
		<div>banana</div>
	{% endmagic %}
</head>
<body>
    {% block fill %}
    {% endblock %}
</body>
</html>
}}}

specific.html
{{{
{% extends ""base.html"" %}

{% block fill %}

<div>
    something specific
</div>

{% endblock fill %}
}}}

And define magic tag to just error
{{{#!python
from django import template

register = template.Library()

@register.tag(name=""magic"")
def do_magic(parser, token):
    nodelist = parser.parse(('endmagic',))
    parser.delete_first_token()
    return MagicNode()

class MagicNode(template.Node):
    def render(self, context):
            raise template.TemplateSyntaxError('oh dear')
}}}

With debug enabled loading a view that renders the specific.html template generates the debug page which displays

{{{
Error during template rendering

In template /home/bob/code/test-template-tag/testtemplatetag/basic/templates/specific.html, error at line 7
oh dear
}}}

And an excerpt from the specific.html template with line seven highlighted (the text ""something specific"").  Instead of the correct line from base.html.

I took a look through the history of the code generating the debug information, I believe it is this change https://github.com/django/django/commit/55f12f8709f0604df7e1817a4c114ead1fb9a311 that has changed the behaviour.  Looking at the tags this was included in 1.9, so I checked out 1.8 and it correctly displays the base.html source code and identifies the magic tag as the line triggering the error.
"	Bug	closed	Template system	1.10	Normal	fixed		Preston Timmons	Accepted	1	0	0	0	0	0
