title: Django template counter in nested loops
body: <p>Hi I have a list of two dictionaries I am passing to a Django template:</p>
  
  <pre><code>base_parts = [
      {'important item': 43},
      {'lesser item': 22, 'lesser item': 3, 'lesser item': 45}
  ]
  </code></pre>
  
  <p>in my template I can do this:</p>
  
  <pre><code>{% for base_part in base_parts %}
      {% for k, v in base_part.items %}
  
      {# ...do stuff #}
  
      {# I try to get a running total of items to use as an ID #}
      inner ID: {% forloop.counter0 %}&lt; br/&gt;
      outer ID: {% forloop.parentloop.counter0 %}&lt; br/&gt;
  
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>As you can see, what I want is a running total of the total number of items I have iterated through, but both methods I have included return duplicates. I know I could concatenate the loops, but I am using a formset and really would like the ids to be indexed 0,1,2...etc.</p>
  
  <p>Is there a way to achieve this type of count in the template?</p>
  
  <p>Any help much appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>output at the moment looks like:</p>
  
  <pre><code>outerID: 0&lt;br /&gt;
  innerID: 0&lt;br /&gt;
  outerID: 0&lt;br /&gt;
  innerID: 1&lt;br /&gt;
  outerID: 1&lt;br /&gt;
  innerID: 0&lt;br /&gt;
  outerID: 1&lt;br /&gt;
  innerID: 1&lt;br /&gt;
  outerID: 1&lt;br /&gt;
  innerID: 2&lt;br /&gt;
  </code></pre>
  
  <p>I want:</p>
  
  <pre><code>totalID: 0&lt;br /&gt;
  totalID: 1&lt;br /&gt;
  totalID: 2&lt;br /&gt;
  totalID: 3&lt;br /&gt;
  totalID: 4&lt;br /&gt;
  totalID: 5&lt;br /&gt;
  totalID: 6&lt;br /&gt;
  totalID: 7&lt;br /&gt;
  totalID: 8&lt;br /&gt;
  totalID: 9&lt;br /&gt;
  </code></pre>