2👍
request.user.trip_set.all
is not a list but a queryset. I think it is the reason of your problem. You can try to change that into a list with the dictsort template filter.
{% if trip in request.user.trip_set.all|dictsort:"id" %}
👤luc
Source:stackexchange.com