eso
eso

Reputation: 103

Django Template comparison inside a loop

I need compare the values of a Model with the result of an aggregate in my template. like a :

{% for valor in valores %}
    {{ valor.quantidade }}
{% endfor %}
results of my loop

{{ total.total_quantidade }}
this is the result of my Aggregate

How i can make the comparison of this values?

List of results of my {% for valor ... %}

1000
2000
3000

result of my aggregate

1500

{% if total.quantidade_total >= valor.quantidade %} shows the equivalent value ..and so on, if smaller shows another value

how can i proceed?

Upvotes: 0

Views: 1018

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239290

What's the difficulty?

{% for valor in valores %}
    {% if total.quantidade_total >= valor.quantidade %}
        Do something
    {% else %}
        Do something else
    {% endif %}
{% endfor %}

Upvotes: 3

Related Questions