We have this model in module X: class A(models.Model): when = models.DateTimeField() type = models.CharField(max_length=10) subtype = models.CharField(max_length=10) data = models.CharField(max_length=100)
I am trying to do something like: SELECT MAX(when), type, subtype, data FROM x_a GROUP_BY type, subtype That is the most recent record for each (type, subtype) pair. As far as I understood there is no way (maybe some undocumented feature...?) to specify a different set of fields for GROUP BY than the ones used in aggregation I need something like: A.objects.group_by('type', 'subtype').aggregate(Max(when)) Is there a way to solve this problem without using extra() ? -- 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.