【发布时间】:2012-12-29 00:11:25
【问题描述】:
我有一个看起来像这样的 Django 模板:
{% if thing in ['foo', 'bar'] %}
Some HTML here
{% else %}
Some other HTML
{% endif %}
问题是它空着回来。如果我切换到这个:
{% if thing == 'foo' or thing == 'bar' %}
Some HTML here
{% else %}
Some other HTML
{% endif %}
它工作正常。有什么原因你不能在 Django 模板中使用 x in list 吗?
【问题讨论】: