Django {% regroup %} and dictsort

I ran into an issue using Django’s {% regroup %} template tag where sometimes a group would be shown twice. It turns out that I needed to use the dictsort filter on the object list, as noted in the documentation, becasue I didn’t have the model ordered by the property I was grouping on.

Here’s the example from the documentation:

{% regroup cities|dictsort:"country" by country as country_list %}

In my case, I needed to filter by a property of the related model:

{% regroup employee.request_set.year|dictsort:"request_type.name" by request_type as type_list %}
Tony Scida @tonyskyday