How do I check if a variable is False using Django template syntax?
{% if myvar == False %}
Doesn\'t seem to work.
Just ran into this again (certain I had before and came up with a less-than-satisfying solution).
For a tri-state boolean semantic (for example, using models.NullBooleanField
), this works well:
{% if test.passed|lower == 'false' %} ... {% endif %}
Or if you prefer getting excited over the whole thing...
{% if test.passed|upper == 'FALSE' %} ... {% endif %}
Either way, this handles the special condition where you don't care about the None
(evaluating to False in the if block) or True
case.