views.html
{% for products in product %}
<tr>
<td>{{ products.quantity_deliver1 }}</td>
<td>{{ products.quantity_deliver2 }}</td>
<td>{{ Code Here }}</td>
</tr>
{% empty %}
<tr>
<td colspan="3" >No Products</td>
</tr>
{% endfor %}
How do I add products.quantity_deliver1 products.quantity_deliver2
and output the sum in the 3rd data cell.
CodePudding user response:
You can use builtin django template tag add
for adding two.
{{products.quantity_deliver1|add:products.quantity_deliver2}}
Ref - https://docs.djangoproject.com/en/dev/ref/templates/builtins/#add