3👍
✅
Jason Culverhouse provided the answer in another similar question i asked.
False and None are treat as variables, instead of constants. If the variables ore not found in the context dictionary, there are resolved to None.
👤goh
3👍
Bizarre. In regular python,
if None == False:
# this will not run
print "abc"
File a bug on Django. 🙂
- [Django]-Django design patterns for overriding models
- [Django]-Django 'instancemethod' object has no attribute '__getitem__'
1👍
This is just the way Python resolves ‘truth’ for comparison between different types.
See the docs. “None” is considered False.
http://docs.python.org/library/stdtypes.html#truth-value-testing
Edit: as below, the python console does not confirm this behaviour, so, I am also surprised. -1 to me!
- [Django]-Django and post request to an external API in different views
- [Django]-Django-REST or Firebase?
- [Django]-Removing from a Haystack/Xapian Index with update_index –remove
- [Django]-Display item numbers with django paginator.
- [Django]-Django distinct on case sensitive entries
0👍
For now It seem like you will have to create your own template filter as was suggested in this post
- [Django]-PostgreSQL saving date in 'Local time zone' while i set it to 'UTC' with Django
- [Django]-How to filter objects on datetime fields?
- [Django]-Missing header files while installing packages using pip
- [Django]-Django ModelChoiceField using distinct values from one model attribute
Source:stackexchange.com