Re: Aggregation across foreign keys / complex aggregation and annotation

2009-01-16 Thread Alex Koshelev
Try this: Process.objects.filter(exchange__input__unit__unit="kilogram")\ .annotate(sum_amount=Sum("exchange__amount"))\ .filter(sum_amount__gt=1) On Fri, Jan 16, 2009 at 12:38 PM, Christopher Mutel wrote: > > Following the general rule that no

Aggregation across foreign keys / complex aggregation and annotation

2009-01-16 Thread Christopher Mutel
Following the general rule that no good deed goes unpunished, I have a question about complex aggregation / annotation or annotation across foreign keys. I have the following simplified model: class Unit(models.Model): unit = models.TextField() class Process(models.Model): process = mod