djangosnippets.org: Latest snippets tagged with 'in'http://djangosnippets.org/tags/in/2010-12-16T04:25:50.283686-06:00is_in
2010-12-16T04:25:50.283686-06:00Tomekhttp://djangosnippets.org/snippets/2292/<p>I know in Django 1.2 we may acquire the same result using
{% if value in arg %} but I need this filter in Django 1.1.
</p>
Freely redistributablein_list filter
2007-08-22T09:03:32.882200-05:00guychihttp://djangosnippets.org/snippets/379/<pre><code>which you would use like this:
The item is
{% if item|in_list:list %}
in list
{% else %}
not in list
{% endif %}
</code></pre>
Freely redistributableIf in list template tag
2007-07-05T03:24:32.652039-05:00udfalksohttp://djangosnippets.org/snippets/302/<p>Given an item and a list, check if the item is in the list</p>
<pre><code>-----
item = 'a'
list = [1, 'b', 'a', 4]
-----
{% ifinlist item list %}
Yup, it's in the list
{% else %}
Nope, it's not in the list
{% endifinlist %}
</code></pre>
Freely redistributable