How to add values after filtered in Django?

Asked

Viewed 283 times

1

Here’s my loop (in my.html template):

{% for item in filter.qs %}
    <tr>
    <th scope="row">{{ item.id }}</th>
    <td>{{ item.nome }}</td>
    <td>{{ item.data|date:"d, F" }}</td>
    <td>{{ item.tipo_pgto}}</td>
    <td>{{ item.mes }}</td>
    <td>{{ item.entrada }}</td>
    <td>{{ item.valor}}</td>
    </tr>
{% endfor %}

The variable {{ item.value }} contains a decimal value. How can I sum them (since it’s a loop) and put the result elsewhere in my html document? It would be better to use Javascript or have some way to make a logic within the view.py and create a temporary storage variable and use it in the template.py?

1 answer

-4

Browser other questions tagged

You are not signed in. Login or sign up in order to post.