Say I have Object model, which has ObjectRevision-s (ObjectRevision
has ForeignKey to Object). I want to fetch from database all latest
ObjectRevision-s. In SQL I can do it like this:

SELECT r1.some_data
FROM objectrevision r1
LEFT OUTER JOIN objectrevision nr2
ON (r1.object_id = r2.object_id AND r1.id < r2.id)
WHERE r2.id IS NULL

What would be be the best way to do it with Django ORM?

--
Tomasz Zielinski
http://pyconsultant.eu
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to