i'm having a lot of trouble with order_by on foreign keys, or namely,
ManyToMany fields.
here's a simplified version of the code:
# holds info about a test (filename, etc.)
class TestInfo(models.Model):
name = models.CharField(max_length=200)
filename = models.CharField(max_length=200, null = True)
# holds info about the execution of test (status, etc.)
class TestResult(models.Model):
info = models.ForeignKey(TestInfo, related_name = "results")
revision = models.IntFielf()
status = models.CharField(max_length = 1, choices =
STATUS_CHOICES)
# holds info about a system that is being tested.
class SystemInfo(models.Model):
name = models.CharField(max_length = 100)
version = models.FloatField()
results = models.ManyToManyField(TestResult, related_name =
"systems")
# a test may be run on several systems and a system
# may be tested by several tests, so it's a ManyToMany
let t be a TestInfo object and i want to get the latest TestResult of
t,
meaning, the latest revision that was executed on the latest the
latest
system version:
latest = t.results.order_by("-revision", "-systems__version")[0]
but trying to order by systems__version fails miserably.
any ideas? or is it just impossible to order by manytomany fields?
-tomer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---