I have a view that returns my sales summary, grouped by sales_date, for example.
[{'sale_date':datetime.datetime(2010,10,5,0,0), 'salesum':2, 'item':1}, {'sale_date':datetime.datetime(2010,10,5,0,0), 'salesum':10,'item':3}, {'sale_date':datetime.datetime(2010,10,6,0,0), 'salesum':1, 'item':1}]
I did grouping inside the template and combined it with html ul and li tags to give me a nice grouping effect based on sales_date
My template grouping is based on this code:
{% regroup salecursor by sale_date|date:"j/m/Y" as salelist %}
and
{{ saleitem.grouper }
Result:
10/10/2010
- item1 Name - 2
- item2 Name - 10
10/10/2010
How to get the total amount for each group, that is, the group should have a total of 12, and the second - only 1 and have some of this effect;
10/10/2010
- item1 Name - 2
item2 Name - 10
Total 12
10/10/2010
Thanks gough
source share