I have the following:
item0 = [{'itemCode': 'AZ001', 'price': 15.52}, {'itemCode': 'AB01', 'price': 31.2}, {'itemCode': 'AP01', 'price': 1.2}]
item1 = [{'itemCode': 'BZ001', 'price': 12.55}, {'itemCode': 'BB01', 'price': 34.1}]
In django template I would like to display the price of the elements of each list by index: 15.52, 12.55 then 31.2, 34.1 then 1.2
List sizes might not be equal, so I am sending the size of the largest list.
Iterating over the max list size:
{{i.item|index:forloop.counter0}}
gets me {'itemCode': 'AZ001', 'price': 15.52}
If I want price, what can I do?
Doing {{i.item|index:forloop.counter0.price}}
is giving me invalid key price at index 0.
In other words, I am sending elements in column order and would like to display them in row order without doing list comprehension using zip on the server.
Any solution?