title: Custom counter in django template
body: <p>I have this code in a django template page</p>
  
  <pre><code>&lt;select class="selectpicker datatable-column-control" multiple
  {% for q_group in question_groups %}
      &lt;optgroup label="{{ q_group.name }}"&gt;
      {% for q in  q_group.questions %}
          &lt;option value="{{ forloop.counter0 }}"&gt;{{ q.title }}&lt;/option&gt;
      {% endfor %}
      &lt;/optgroup&gt;
  {% endfor %}
  </code></pre>
  
  <p></p>
  
  <p>I want a value for every option tag that increases in each iteration. If I have 10 option tags, then their values will be from 0 to 9. 
  <code>forloop.counter0</code> does not fulfill my need as the inner loop counter initializes to 0 when outer loop finishes once.</p>