[Django]-Django regroup odd behavior

9👍

The problem is that Django’s regroup depends on the list being ordered by the attribute you’re regrouping by. See the docs:

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

Thus, change:

missed_routes = Donor.objects.filter(missed='YES').order_by('pickup_date')  

to

missed_routes = Donor.objects.filter(missed='YES').order_by('pickup_id')  

Leave a comment