I have seen other posts on this topic but it seems that it was on the old trunk. I am using Django version 1.1 and I am unable to sort by foreign key
When I try and execute the following query Result.objects.select_related().order_by('StatusId.Status') I get 0 rows retrieved. Is that the correct way to order by foreign keys? Here are the models in question class Result( models.Model): TestName = models.CharField( max_length=100) TestVersion = models.CharField( max_length=50, null=True) ExecutionStartDate = models.DateTimeField( verbose_name = "Start Date", null=True) StatusId = models.ForeignKey( Status, verbose_name = "Status", db_column='StatusId', related_name="OverallStatus") AutoStatusId = models.ForeignKey( Status, verbose_name = "Status", db_column='AutoStatusId', related_name="AutoStatus") PrintVerifyStatusId = models.ForeignKey( Status, verbose_name = "Status", db_column='PrintVerifyStatusId', related_name="PrintVerifyStatus") ImageVerifyStatusId = models.ForeignKey( Status, verbose_name = "Status", db_column='ImageVerifyStatusId', related_name="ImageVerifyStatus") ExecutionTime = models.DecimalField( max_digits=10, decimal_places=4) StationId = models.ForeignKey( Station, verbose_name = "Station", db_column='StationId') SubmitDate = models.DateTimeField( verbose_name="Submit Date", null=True) Owner = models.CharField( max_length=100) ProjectId = models.ForeignKey( Project, verbose_name = "Project", db_column='ProjectId') PhaseId = models.ForeignKey( Phase, verbose_name = "Phase", db_column='PhaseId') TestTypeId = models.ForeignKey( Type, verbose_name = "Test Type", db_column='TestTypeId') UserInterventionFlag = models.BooleanField( default=False) CurrentFlag = models.BooleanField( default=True) ActiveFlag = models.BooleanField( default=True) objects = models.Manager() # The default manager. config_objects = ResultManager() class Status( models.Model): Status = models.CharField( max_length=100) AutoFlag = models.BooleanField() Thanks, Jeff --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---