I am new to the world of Python. I have this 'if statement'
in my jinja2 template:
{{context.disabled==True and "Yes" or "No"}}
I am not sure what this syntax is called, but it works like an if
.
php equivalent would be: echo $disabled ? "Yes" : "No"
This is always returning No
or False
even though context.disabled
is True
,
Why is it behaving like this? I cant see why it is doing this, am I doing it wrong?
Not sure about boolean expressions in jinja templates, but you can use conditions:
{% if context.disabled %} "Yes" {% else %} "No" {% endif %}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments