On 16-01-12 10:10, snow leung wrote:
my filter return dictionary like this:
{{ somevalue | dic_filter }}
but when i try this
{%for itm in somevalue | dic_filter %}
{{itm}}
{%endfor %}
it only print the key
how can i get the value with this ?
It is the same in Python. Looping over a dict returns the keys:
>>> my_dict = {'a': 'aaa',
... 'b': 'bbb'}
>>> for key in my_dict:
... print key
a
b
If you want the values for those keys, you must use the key to get it
out of the dict:
>>> for key in my_dict:
... print my_dict[key]
aaa
bbb
In your case:
{% for itm in somevalue | dic_filter %}
{{ somevalue.itm }}
{% endfor %}
(And I'd replace 'itm' with 'key')
Reinout
--
Reinout van Rees http://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.