﻿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
5831	Template Debug highlights wrong {% for %} tag	Charmless <jim-django@…>	Vladimir Moskva	"When an exception happens within a for tag's head, the error source is assigned always assigned to the top-level for loop, even if the erroneous for tag is nested.

Example:
{{{
{% for a in as %}
  {% for b in a.bs %}
    {% for c in b.relatedobject_set %}
       {{ c.foo }}
    {% endfor %}
  {% endfor %}
{% endfor %}
}}}

The error here is at ""b.relatedobject_set"", which should be ""b.relatedobject_set.all"" (assuming b is a model related to a model releatedobject).

As is, the template debug system marks the top level for tag, ""{% for a in as %}"", as being the point of error. The correct place to mark is the for tag where the error happened.

Attached is a patch that fixes this. I'm not familiar with Django's tag tests, so I can't include any, but would be happy to learn and supply some if it is agreed that this is a correct fix."	Bug	closed	Template system	dev	Normal	fixed	debug for toplevel nesting	m@…	Ready for checkin	1	0	0	0	0	0
