Reputation: 248
I have a dictionary
>>> filterdata
{u'data': [{u'filter': u'predictions', u'filtervalue': u'32', u'filterlevel': u'cltv', u'filtertype': u'>'}, {u'filter': u'profile', u'filtervalue': u"'TOMMY'", u'filterlevel': u'firstname', u'filtertype': u'='}]}
and i am using this to in django template
{% for c in filterdata.data %}
{{c}} ## print the current iterating dictionay
{% for d in c.items %}
{{ d.filtervalue }} ## does not print anything
{% endfor %}
{% endfor %}
any idea what i am doing wrong
Upvotes: 1
Views: 1526
Reputation: 600059
You're iterating too much. d
is the set of key-value pairs in the dict; filteritems
is one of those keys, not an attribute of the pairs themselves. Remove that inner loop.
{% for c in filterdata.data %}
{{ c.filtervalue }}
{% endfor %}
Upvotes: 1