我有一个看起来像这样的Django模板:
{% if thing in ['foo', 'bar'] %}
Some HTML here
{% else %}
Some other HTML
{% endif %}
Run Code Online (Sandbox Code Playgroud)
问题是它回来了.如果我切换到这个:
{% if thing == 'foo' or thing == 'bar' %}
Some HTML here
{% else %}
Some other HTML
{% endif %}
Run Code Online (Sandbox Code Playgroud)
它工作正常.有没有什么理由你不能x in list在Django模板中使用?