[Answer]-Template filter common Q of if equal True

1👍

As @PepperoniPizza mentions in the comments above, in Python it’s not recommended to compare values to True or False using ==. Most of the time, you only need to use {% if result %} in your template — it doesn’t matter whether result is True, 1, or some other value than evaluates to True.

If you really need to do {% if result == True %}, this will work in Django 1.5. From the release notes:

The template engine now interprets True, False and None as the corresponding Python objects.

Leave a comment