[Answered ]-Django: get confused with regroup in template

2👍

You need to be sure that your data is already sorted by the value you are regrouping on.

The documentation for the regroup tag does explain this:

Note that {% regroup %} does not order its input! Our example relies on the fact that the cities list was ordered by country in the first place. If the cities list did not order its members by country, the regrouping would naively display more than one group for a single country.

Leave a comment