1👍
I suspect that in model Meta section you have set model ordered by an ‘external’ field (related model 'station__departure_time'
). When you write query django make joins to this ‘external’ field for sorting purposes.
In this case you should use distinct()
method or clear ordering using .order_by()
Source:stackexchange.com