How to chcek if a variable is “False” in Django templates?

For posterity, I have a few NullBooleanFields and here’s what I do:

To check if it’s True:

{% if variable %}True{% endif %}

To check if it’s False (note this works because there’s only 3 values — True/False/None):

{% if variable != None %}False{% endif %}

To check if it’s None:

{% if variable == None %}None{% endif %}

I’m not sure why, but I can’t do variable == False, but I can do variable == None.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)