私のdjango htmlページで次のことをしたい:
{% if myList|length and ifequal myValue 'somestring' %}
blah blah
{% endif %}
しかし、私はエラーを受け取ります: 未使用の 'myValue ' at end of if expression
テンプレートで If AND を実行するにはどうすればよいですか??
これを試して:
{% if myList|length and myValue == 'somestring' %}
blah blah
{% endif %}
django テンプレートでのboolean-operatorsとcomplex-expressionsの使用については、django のドキュメントを参照してください。
次のようになります。
{% if myList|length and myValue == 'somestring' %}
blah blah
{% endif %}
if
theと theifequal
を 2 つのステートメントで分離する必要があると思います。
{% if myList|length %}
{% ifequal myValue 'somestring' %}
blah blah
{% endifequal %}
{% endif %}