Re: Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
dget__budge__in= > self.budget_set.all()).aggregate(Sum('total'))['total__sum'] > > try like this..! > > On Wed, Feb 1, 2017 at 7:14 PM, Patrick Joy > wrote: > >> Hi all, >> >> Would appreciate some advice on this, I'm having trouble working out

Aggregation and following relationships backwards multiple levels

2017-02-01 Thread Patrick Joy
Hi all, Would appreciate some advice on this, I'm having trouble working out the best way to aggregate across multiple foreign key relationships. I have come up with the solution below however I'm not sure if this is the correct way to handle this situation. Any advice would be appreciated. Th

Help required using pre_fetched data in aggregate()

2013-08-24 Thread Patrick Joy
Hi all, Would appreciate some help on how to optimise the following piece of code. I have two models, "invoice" and "invoice item". The invoice total is calculated in invoice_total() by aggregation the sub_total and tax_total from all invoice_items (see code below). The problem I have is that