[Solved]-Is it possible, in a django template, to check if an object is contained in a list


Go here. Very similar to what they’re using on trunk. “Save this as smart_if.py in the templatetags folder of one of your apps. Then a simple {% load smart_if %} replaces the boring built-in Django {% if %} template with the new smart one.”


If you’re using latest django version, then it’s just

{% if entry in likes %}

Refer django docs


If you’re not running trunk one of the following should work:


Replacement “if” tag, largely the basis for the new functionality in the upcoming 1.2 release:

Leave a comment