Reputation: 271624
Suppose my model is this:
class Ego(models.Model):
event = models.ForeignKey(Event)
user = models.ForeignKey(User)
As you can see, this table has 2 columns, and they're both foreign keys. How do I "order by" User.first_name?
Is this it? But it doesn't look like it.
Ego.objects.all().order_by("User.first_name")
Upvotes: 1
Views: 125
Reputation: 271624
Solved.
I did this:
Ego.objects.all().select_related.order_by("auth_user.first_name")
Upvotes: 3