If you set the context variable (e.g. 'woot') as None or just leave it undefined ....
{% if woot%} Yes! {% endif%}
Is there something you expect (nothing). But if you do this:
{% if woot == True%} Yes! {% endif%}
He will print "Yes!" although woot is None / undefined. It seems very unintuitive. Obviously, I can get around this ... but I would like to understand the root cause. Any ideas why this is happening ....?
Evidence:
from django.template import Context, Template x = Template("{% if woot %}Yeah!{% endif %}") y = Template("{% if woot == True %}Yeah!{% endif %}") x.render( Context( {} ))
This is on Django 1.4.3
source share