1👍
✅
Your logic is flawed, use:
{% if item.category == '1' or item.category == '3' %}
and:
{% if item.category == '2' or item.category == '4' %}
The expression item.category == 2 or 4
does not mean what you think it does; it is interpreted as (item.category == 2) or 4
instead. If item.category
is indeed 2
, then that expression evaluates to (True) or 4
, but if item.category
is 3
that becomes (False) or 4
, returning 4
, which is considered True
in a boolean context.
Moreover, you have strings in item.category
, but you were testing against int
values instead.
Source:stackexchange.com