[Answered ]-Django template find dictionary in list

2๐Ÿ‘

โœ…

I think it will probably be better if, rather than trying to deal with this data structure in the template, you collapse that into a dict like:

aggregate_dict = {<id_1>:<val_1>,...}

so that you can more easily look up the values in the template as {{aggregate_dict.<id_n>}} instead.

you could do that with a little loop like:

aggregate_dict = {}
for item in your_old_list:
  aggregate_dict[item[foo]] = item[bar]

Leave a comment