Totals/Subtotals in Django template
问题 I'm having difficulty wrapping my head around a simple problem. How do you calculate totals and subtotals in a django template? Let's say I want to generate a report of customer's orders, something like: Desired Report Output Customer1 1 Widgets $ 2 1 Bobbins $ 1 Subtotal $ 3 Customer2 2 Widgets $ 4 2 Bobbins $ 2 Subtotal $ 6 TOTAL $ 9 Let's assume we populate a dictionary in our view orgs = {} orgs['Customer1'] = [ { 'qty': 1, 'descr' : 'Widgets', 'price': 2 }, { 'qty': 1, 'descr' : 'Bobbins