Reputation: 372
I have this structure in a tag called items_value:
{
('prog1','date1'): {
'total_error': 4256,
'components1': [{
'errors': 5,
'lines': 1
}],
'components2': [{
'errors': 5,
'lines': 1
}
],
('prog2','date2'): {
'total_error': 4256,
'components1': [{
'errors': 5,
'lines': 1
}
]
}
How a get the values inside each tuple in Django? I tried:
{% for elem in items_value %}
but the result is:
('prog1','date1')
('prog2','date2')
I want, for exemple:
{
'total_error': 4256,
'components1': [{
'errors': 5,
'lines': 1
}],
'components2': [{
'errors': 5,
'lines': 1
}
}
Upvotes: 0
Views: 1492
Reputation: 37344
Iterating over a dictionary gives you its keys. To get its values, iterate over items_value.values()
. Or, in a template, {% for value in items_value.values %}
. Note that Python dictionaries are unordered, so there are no guarantees about what order you'll get the values in.
Upvotes: 1
Reputation: 1021
You can loop over the values:
{% for value in items_value.values() %}
Upvotes: 0