开发者

right way to use if else in django template? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_开发技巧 Closed 10 years ago.
{% if {{result}} == 'Invalid' %}
 <span class="error-message-uname">Invalid .</span>
{% endif %}


That depends on what version of Django you're using. Since Django 1.2, this is valid:

{% if result == 'Invalid' %}
    <span class="error-message-uname">Invalid .</span>
{% endif %}

For earlier versions, use ifequal:

{% ifequal result 'Invalid' %}
    <span class="error-message-uname">Invalid .</span>
{% endifequal %}


{% if result == 'Invalid' %}
    <span class="error-message-uname">Invalid .</span>
{% endif %}

See Django doc

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜