Just hit this issue and had a hard time figuring out what I've done wrong.
Intuitively I tried .distinct('related_id').order_by('related_id')
after realizing removing my Related._meta.ordering
solved the issue but, as pointed out by akaariai, this is not allowed ATM.
Replying to akaariai:
I think we should allow using .order_by('team_id') here.
Related fields have two attributes on model level - team and team_id in this case. We allow using team_id in many places in the ORM already, and to me it seems we should allow it in order_by and distinct, too.
Is there some reason to *not* allow them?
I can't think of any reason we'd like *not* to allow them. It looks like sanest to expose an API to explicitly opt-out of the existing related model ordering behavior while maintaining backward compatibility.