条件检查列表中是否存在值。?

时间:2014-10-16 09:46:22

标签: python django django-templates

昨天我问了类似的问题inside-for-loop-if-condition-not-working-in-django,但现在我有了复选框才能工作

{% for items in store %}
<div class="col-xs-6"><input type="checkbox" value="{{ items.id|safe }}"{% if items.id in get.some_var %} checked="checked" {% endif %} name="store[]" id="check{{ forloop.counter }}" class="checkBox store">
<label for="check{{ forloop.counter }}">{{ items.name }}{{ items.id }}{{ get.some_var|safe }}</label>
</div>
{% endfor %}

get.some_var来自会话,价值为[u'1', u'3']

items.id1等...

因此,如果1get.some_var匹配,那么相应的checkboxactive,但遗憾的是,这不起作用。

你能指出这里的错误。?

0 个答案:

没有答案
相关问题