﻿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
12486	Accessing dict values via a value of a variable as key	uggsrock	nobody	"In the current release (and previous releases also) there is no way to access the value of a dict or other struct with the value of a variable as the key. For example if you want to have more than one struct you want to iterate over and get a key-value-based table with the data of other structs in it, you either have to do it manually inside the normal python code or with very ugly filters.

Here is a simple example i mentioned before:
(we have dictionary1 and dictionary2 with the same size and keys)
{{{
{% for key,value in dictionary1.items %}
<li>{{key}}: {{value}}, {{dictionary2.key}}</li>
{% endfor %}
}}}
[[BR]]
This wouldn't work because it would search for dictionary2.key or dictionary[ ""key"" ] (so key is the string ""key"", not a variable)
[[BR]]But to get example working you would need it to call dictionary[ key ] whereas the key is a variable and its value would be used as a key.
Most solution with filters look this way:

{{{
@register.filter
def lookup(d, key):
    return d[key]
}}}
(took this one from [http://push.cx/2007/django-template-tag-for-dictionary-access]

As you see, there is just this ugly (and by the way also slow) way through filters but no real one the template engine should provide itself. Therefore i would suggest to take something like ""dict[ var ]"" or ""dict[ inner_dict[ var ] ]"" as the shortcut for the template engine to provide this usefull feature."		closed	Template system	1.1		wontfix			Unreviewed	0	0	0	0	0	0
