django 模版语法,if

if 标签

{% if %}会对一个变量求值,如果它的值是“True”(存在、不为空、且不是boolean类型的false值),对应的内容块会输出。

{% if num > 100 or num < 0 %}
    <p>无效</p>
{% elif num > 80 and num < 100 %}
    <p>优秀</p>
{% else %}
    <p>凑活吧</p>
{% endif %}

 

 

 

 

 

参考:

https://www.cnblogs.com/lshedward/p/10351148.html 

 

 

posted @ 2020-07-17 00:26  anobscureretreat  阅读(418)  评论(0编辑  收藏  举报