Answer the question
In order to leave comments, you need to log in
How in Django 2.2 to make the "if" condition inside the "for" work?
hello, this is it:
<tbody>
{% for i in all %}
<tr>
<td class="grey"> {{ i.0 }} </td>
<td class="grey">{{ i.1 }}</td>
<td class="thick">{{ i.2 }}</td>
<td>{{ i.3 }}</td>
<b><td style="color: {% if i.4|floatformat > 0 %} green {% else %} red {% endif %} ;"> {{ i.4 }} </td> - не работает
<td style="color:{% if i.4|floatformat > 0 %} green {% else %} red {% endif %};"> {{ i.5 }} </td> </b> - не работает
</tr>
{% endfor %}
</tbody>
Answer the question
In order to leave comments, you need to log in
Throw out the filter |floatformat. It gives a string representation of a number
greater than 0 means there can be values and less? If only 0 or more, then you can generally write {% if i.4 %}.
If there can be negative ones, then make sure that there will be no lines and {% if i.4 > 0 %}
Something like this...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question