title: How can i implement a running total in django Template?
body: <p>I have a view that returns my sales summary grouped by sales_date e.g.</p>
  
  <pre><code>[{'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}]
  </code></pre>
  
  <p>I have done the grouping inside the template, and combined it with html <strong>ul</strong> and <strong>li</strong> tags to give me a nice grouping effect based on the sale_date</p>
  
  <p>My template grouping is based on this code:</p>
  
  <pre><code>{% regroup salecursor by sale_date|date:"j/m/Y" as salelist %}
  </code></pre>
  
  <p>and</p>
  
  <pre><code>{{ saleitem.grouper }
  </code></pre>
  
  <p>The result is:</p>
  
  <p><strong>05/10/2010</strong></p>
  
  <ul>
  <li>item1 Name - 2</li>
  <li>item2 Name - 10</li>
  </ul>
  
  <p><strong>06/10/2010</strong></p>
  
  <ul>
  <li>Item1 Name - 1</li>
  </ul>
  
  <p>How do u get a running total for each group i.e. group one should have a total of 12 and the second group a total of 1 and have something of this effect;</p>
  
  <p><strong>05/10/2010</strong></p>
  
  <ul>
  <li>item1 Name - 2</li>
  <li><p>item2 Name - 10</p>
  
  <p><strong>Total 12</strong></p></li>
  </ul>
  
  <p><strong>06/10/2010</strong></p>
  
  <ul>
  <li><p>Item1 Name - 1</p>
  
  <p><strong>Total 1</strong></p></li>
  </ul>
  
  <p>Thanks
  Gath</p>