接着Django模板-基础知识继续写模板相关知识. if标签 {% if %} 标签接受 and , or 或者 not 关键字来对多个变量做判断 ,或者对变量取反( not ). 但是不允许在同一个标签中同时使用 and 和 or,下边是不合法的: {% if athlete_list and coach_list or cheerleader_list %} 多次使用同一个逻辑操作符是没有问题的,但是我们不能把不同的操作符组合起来. {% if athlete_list or coach_l
一.if/else{% if %} 标签检查(evaluate)一个变量,如果这个变量为真(即,变量存在,非空,不是布尔值假),系统会显示在 {% if %} 和 {% endif %} 之间的任何内容,例如: {% if today_is_weekend %} <p>Welcome to the weekend!</p> {% endif %} {% else %} 标签是可选的: {% if today_is_weekend %} <p>Welcome to the