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!