[Django]-Django template: How can I regroup a list of dictionaries by a nested property of each dictionary?

0👍

Writing a custom filter would be one direction to take since it is not straightforward to use regroup, you can write a custom filter; pass your lists of dictionaries to it and using group by using the key that you want to order by or filter with.

Custom filters – https://docs.djangoproject.com/en/2.0/howto/custom-template-tags/

Itertools group by – https://docs.python.org/2/library/itertools.html

Leave a comment