> I was unclear, but SQL should explain what I want to do - select > all ObjectRevision-s that are latest in Object-s that they belong to. > Moreover, I want to do this in with one ORM query, without resorting > to SQL or splitting the query too much.
I'd go for a denormalized database: class Foo(models.Model): latest_revision = models.OneToOneField('FooRevision', related_name='latest_revision_for') ... class FooRevision(models.Model): foo = models.FogeignKey(Foo) ... That way you can easily query Foo.objects.all().select_related() and be done. It'll be faster than your rather complex DB query and can be handled in the Django ORM. I'd say it's a win win situation. --mp --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---