﻿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
29740	Wrong lines shown on ValueError when rendering template with a bad for-loop	Vasili Korol	nobody	"Consider the following setup:

1. There is a top level template (main.html):
{{{
<!DOCTYPE html>

{% load staticfiles %}
{% load compress %}
{% load cms_tags sekizai_tags %}
{% load solo_tags %}
{% load lists %}
{% load userextras %}

{% get_solo 'maintenance.SiteConfiguration' as site_config %}

... Long template body ....

{% block content %}
{% endblock %}
...
}}}

2. A child template ""taskclasses.html"" that extends ""main.html"":
{{{
{% extends ajax|yesno:""ajax.html,main.html"" %}
                                              
{% load staticfiles %}                        
{% load compress %}                           
{% load userextras %}                         
...
                                              
{% block content %}                           
    ...
    {% for group, task_classes in task_classes_grouped %}
        ....
    {% endfor %}
    ...
{% endblock %}
}}}

In my case, `task_classes_grouped` was a `dict`, so the ""for"" loop in ""taskclasses.html"" is invalid. This expectedly results in a `ValueError`, but the exception is reported wrongly:

{{{
ValueError at /projects/1/taskclasses
Need 2 values to unpack in for loop; got 1. 

Request Method:	GET
Request URL:	http://devel:20062/projects/1/taskclasses
Django Version:	1.11.15
Exception Type:	ValueError
Exception Value:	
Need 2 values to unpack in for loop; got 1. 
Exception Location:	/usr/local/lib/python3.4/dist-packages/django/template/defaulttags.py in render, line 207
Python Executable:	/usr/local/bin/uwsgi
Python Version:	3.4.3
Python Path:	
['/www/deploy/lib',
 '/data/programs/openbabel/lib/python3.4/site-packages/',
 '/www/deploy/apps/',
 '.',
 '',
 '/usr/lib/python3.4',
 '/usr/lib/python3.4/plat-x86_64-linux-gnu',
 '/usr/lib/python3.4/lib-dynload',
 '/usr/local/lib/python3.4/dist-packages',
 '/usr/lib/python3/dist-packages',
 '/www/deploy']
Server time:	Thu, 6 Sep 2018 11:52:03 +0000

...
Error during template rendering
In template /www/deploy/viking/templates/main.html, error at line 0

Need 2 values to unpack in for loop; got 1.
1	<!DOCTYPE html>
2	
3	{% load staticfiles %}
4	{% load compress %}
5	{% load cms_tags sekizai_tags %}
6	{% load solo_tags %}
7	{% load lists %}
8	{% load userextras %}
9	
10	{% get_solo 'maintenance.SiteConfiguration' as site_config %}
}}}

This does not include the line that actually failed, and the template reference is wrong (parent template instead of the child).
"	Bug	closed	Template system	1.11	Normal	duplicate	template, valueerror, reporting		Unreviewed	0	0	0	0	0	0
