title: how to do calculation inside for loop in django template
body: <p>I have to do some calculation in django template inside for loop, but it it is not parsing python code inside for loop and giving error</p>
  
  <pre><code>{% for ticket in tickets_in_cart %}
      &lt;div class="davis-date-time"&gt;
          &lt;h3&gt;{{ ticket.performance_id__event_start_date|date:"M d" }}&lt;/h3&gt;
          &lt;p&gt;{{ ticket.performance_id__timing }}&lt;/p&gt;
      &lt;/div&gt;
      &lt;div class="davis-date-time"&gt;
        &lt;h3&gt;{{ ticket.performance_id__city }}&lt;/h3&gt;
        &lt;p&gt;{{ ticket.performance_id__venue }}&lt;/p&gt;
      &lt;/div&gt;
      {% singleAmount = ticket.tickets_count*ticket.tickets_amount %}
      {% finalAmount += singleAmount %}
  
  {% endfor %}
  </code></pre>
  
  <p>I have to do this because i need to print this finalAmount variable value outside of the for loop.</p>