Hi, > I can't order the results of a queryset by a field in a related > table..
Have you seen: http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-fields > I have this set of applications (they are far more complex, i'm > cutting out all the unnecessary parts): > > images app: > class Subject(models.Model): > photographer = models.ForeignKey(Author) > [... a lot more stuff..] > > class Shoot(models.Model): > subject = models.ForeignKey(Subject) > [... again a lot more stuff..] > > class Version(models.Model): > shoot = models.ForeignKey(Shoot) > [...yet even more stuff.. ] > > lists app: > class Author(models.Model): > name = models.CharField(max_length=50) > surname = models.CharField(max_length=50) > > So basically the relation goes like: version <- shoot <- subject -> > author > > Ok.. i need to order the results of a Version.objects.all() query by > author surname... with no success.. can someone help me to write the > correct syntax to do this? You didn't mention what you've tried so far that didn't work for you. Have you tried the following? Version.objects.all().order_by('shoot__subject__photographer__surname') -Rajesh D --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---