Re: queryset with extra and aggregate fails

2009-11-05 Thread davisd
Okdoke, well here's an inventive workaround for now, hope this helps someone else. calculated_items = Item.objects.filter(cart=self).extra(select= {'calculated_price': 'SUM(unit_price * quantity)'})[:1] return calculated_items[0].calculated_price if calculated_items.count () > 0 else 0 I should

Re: queryset with extra and aggregate fails

2009-11-05 Thread Karen Tracey
On Thu, Nov 5, 2009 at 4:10 PM, davisd wrote: > > Adding an extra field (calculated_price): > > calculated_items = Item.objects.filter(cart=self).extra(select= > {'calculated_price': 'unit_price * quantity'}) > > works great and the queryset items have the new

queryset with extra and aggregate fails

2009-11-05 Thread davisd
Adding an extra field (calculated_price): calculated_items = Item.objects.filter(cart=self).extra(select= {'calculated_price': 'unit_price * quantity'}) works great and the queryset items have the new calculated_price field. calculated_items.aggregate(Sum('calculated_price')) raises an