【发布时间】:2009-12-24 23:11:14
【问题描述】:
如何使用“in”语句来检查列表中的项目与否。如果我使用:
{% for picture in pictures %}
{% if picture in article.pictures %}
<input type="checkbox" checked="true" name="picture" value="{{ picture.key }}" />
{% else %}
<input type="checkbox" name="picture" value="{{ picture.key }}" />
{% endif %}
<img src='/img?img_id={{ picture.key }}'></img> <br />
{% endfor %}
这失败了:
TemplateSyntaxError: 'if' statement improperly formatted
上线
{% if picture in article.pictures %}
帮助?
【问题讨论】:
-
假设 Django 模板,看起来它可能在 Django 1.2 (code.djangoproject.com/ticket/8087) 中。不过,不知道这是否对您有帮助。
标签: python google-app-engine templates