In the html template of my Django app, I am trying to have a "total" variable that would sum attributes together (using the {% with %} tag), but the result displayed on the webpage is always 0 and I can't figure out why.
Here is my HTML code:
<table id="managerTable" class="display compact" width="100%">
{% for manager in manager_list %}
<thead>
<tr>
<th><strong>{{manager}}</strong></th>
<th>Proj1</th>
</tr>
</thead>
<tbody>
{% with total=0 %}
{% for player in player_list %}
<tr>
{% if player.owner == manager %}
<td>{{player.web_name}}</td>
<td>{{player.exp_x_score_1}}</td>
{% with total=total|add:player.exp_x_score_1 %}
{% endwith %}
{% endif %}
</tr>
{% endfor %}
<tr>
<td></td>
<td></td>
<td><strong>TOTAL</strong></td>
<td><strong>{{total}}</strong></td>
</tr>
{% endwith %}
</tbody>
{% endfor %}
</table>
The attribute player.exp_score_1 is well displayed and non 0.