django 1.3 templatestag if string contains list of strings
How can I check if a string is one of a list of values
('image_1', 'image_2'..etc)
How can check if a string equal to one开发者_开发知识库 of the values in the list? In python, an equavilant would be
if 'mystring' in ('yes' ,'no', 'mystring'):
return True
how can i do the above using django templatetags?
Django templates come with thein
operator as well.
{% if some_string in some_list %}
Do something
{% endif %}
This was first introduced in django 1.2 as one of the operators supported by the "smart" if
tag.
精彩评论