from decimal import Decimal def compute_quote_totals(quote): subtotal = sum([Decimal(str(i.line_total)) for i in quote.items]) quote.subtotal = subtotal quote.total = subtotal