[Answer]-How easily add subtotals in Django

1👍

I know this is late, but for anyone who stumbles upon this I’m sure it is a problem with >>>q.aggregate(Sum(F('price_sale')*F('quantity')), output_field=FloatField()).

the output_field named argument is a parameter of Sum, not aggregate so it should be >>>q.aggregate(Sum(F('price_sale')*('quantity'), output_field=FloatField())). I know you said 1.7–outdated now– but the 1.9 docs on aggregation make this clear. But it is a small mistake that I made too.

Leave a comment