Is it possible to make the groupby
filter order in descending order? I have a list of dictionaries from a SQL query and I want to group by date in descending date order. From the manual:
{% for group in persons|groupby('gender') %}
<li>{{ group.grouper }}<ul>
{% for person in group.list %}
<li>{{ person.first_name }} {{ person.last_name }}</li>
{% endfor %}</ul></li>
{% endfor %}
Try applying the reverse
filter to the groupby('attribute')
filter (e.g., {% for group in persons|groupby('gender')|reverse %}
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With