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

0👍

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.”

18👍

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

{% if entry in likes %}

Refer django docs

-1👍

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

Filter:

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

Leave a comment