Thank you akaariai That put me on the right track.
Log.objects.distinct('thing__id').order_by('thing__id', '-modified_on').select_related().filter(thing__deleted=0)[:20] By avoiding the use of values() I was able to then use the result as an object and access everything I needed. The above ORM statement however does not look as elegant to read as I have come to expect from Django though. The resulting SQL doesn't seem too shabby however. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ubxdckMp2HwJ. 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.