django templates jinjia2

django 的templates 判断语法是采用jinjia2的语法

语法如下

for 循环

<ul>
{% for athlete in athlete_list %}
    <li>{{ athlete.name }}</li>
{% endfor %}
</ul>

 

 

if 判断

{% if athlete_list %}
    Number of athletes: {{ athlete_list|length }}
{% elif athlete_in_locker_room_list %}
    Athletes should be out of the locker room soon!
{% else %}
    No athletes.
{% endif %}

 

posted @ 2016-02-18 15:48  zhaogaolong  阅读(274)  评论(0编辑  收藏  举报