Django: Group by?
Posted
by Mark
on Stack Overflow
See other posts from Stack Overflow
or by Mark
Published on 2010-03-13T01:43:58Z
Indexed on
2010/03/13
1:47 UTC
Read the original article
Hit count: 338
django
I'm looking for something like the following:
previous_invoices = Invoice.objects.filter(is_open=False).order_by('-created').group_by('user')
(group_by()
doesn't exist)
This would find the most recently closed invoice for each user. This aggregation API seems to let you do stuff like this for counts and sums, but I don't need a count or sum or anything, I actually want the invoice objects!
© Stack Overflow or respective owner