开发者

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

开发者 https://www.devze.com 2023-01-31 06:02 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
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

精彩评论

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