You can use the template language to test against what you think are constants, 
the parser is actually testing 2 "literals".

The parser tests for 2 literals with names 'None' and 'False'.
When parser tries to resolve these in the context a VariableDoesNotExist 
exception is thrown and both objects resolves to the python value None
and None == None.

>>> from django.template import Context, Template
>>> t = Template("{% if None == False %} not what you think {% endif %}")
>>> c = Context({"foo": foo() })
u' not what you think '

>>> c = Context({'None':None})
>>> t.render(c)
u' not what you think '

>>> c = Context({'None':None, 'False':False})
>>> t.render(c)
u''

Jason
 
On Apr 14, 2011, at 7:59 PM, carrier24sg wrote:

> 
> 
> Hi guys,
> 
> {% if None == False %}
>    abc
> {% endif %}
> 
> Strangely my template displayed abc. Any explanation?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to