In a django template, for each category, I iterate through each subcategory. But how do I sort the subcategories? I need it to be flexible so I can choose what I sort on.
{% for cat in categories %}
{% for subcat in cat.subcategories_set.all%}
{% endfor %}
{% endfor %}
You can use the
dictsorttemplate tag, it lets you can sort by any of the keys. Documentation