1
我有這個在我的Django 1.2模板:我是否使用django if template tag wrong?
{% for m in model.related.iterator %}
{% if "str" or "Str" in m %}
{{m}}//I don't want anything here but put this in so I could see the output
{%else%}
{% if forloop.last %}
{% customtag "var" %}
{% endif %}
{% endif %}
{% endfor %}
我得到的{{m}}
如果它包含"str"
,"Str"
或者兩者都不是的,無論價值。此外,如果我拿出or
並比較一個字符串的作品,但我想比較兩個沒有另一個else if
。任何方式來做到這一點?
沒錯,'{%如果 「STR」 或「海峽「in m%}」表示「if」str「」的值爲True,所以if語句的其餘部分甚至都不會被評估。 – Ngenator 2013-03-02 06:53:05
非常感謝!這正是我所期待的。 – 2013-03-02 21:40:30