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
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
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
3 matches
Mail list logo