{% regroup messages by category as type_list %} {% for type in type_list %} {% endfor %} {% for message in messages %} {% endfor %}