[Answered ]-Order template when using _set.all

2👍

You can add a helper to your model:

class Sequel_Film( models.Model ):
    ...

    def ordered_film_set(self):
        return self.film_set.all().order_by('anno__anno')

In template:

{% for sequel in film.sequels.all %}
    {% for sequel_film in sequel.ordered_film_set %}
        {{sequel_film}}
    {% endfor %}
{% endfor %}
👤CJ4

Leave a comment