{%forathleteinathlete_list%}{{athlete.name}}{%endfor%}
{%forx,yinpoints%}There is a point at {{x}},{{y}}{%endfor%}
{%forkey,valueindata.items%}{{key}}: {{value}}{%endfor%}
Variable | Description |
---|---|
forloop.counter | 显示序号(从1开始) |
forloop.counter0 | 显示序号(从0开始) |
forloop.revcounter | 显示序号(倒序,从1开始) |
forloop.revcounter0 | 显示序号(倒序,从0开始) |
forloop.first | 如果元素是第一个元素,则返回值为True |
forloop.last | 如果元素师最后一个元素,则返回值为True |
forloop.parentloop | 如果是一个嵌套的循环,那么引用外面的forloop遍历 |
{%forathleteinathlete_list%}{{athlete.name}}{%empty%}Sorry, no athlete in this list!{%endfor%}
{%ifathlete_list%}{%forathleteinathlete_list%}{{athlete.name}}{%endfor%}{%else%}Sorry, no athletes in this list.{%endif%}
{%ifathlete_list%}Number of athletes: {{athlete_list|length}}{%elifathlete_in_locker_room_list%}Athletes should be out of the locker room soon!
{%else%}No athletes.
{%endif%}
{%ifathlete_listandcoach_list%}Both athletes and coaches are available.
{%endif%}{%ifnotathlete_list%}There are no athletes.
{%endif%}{%ifathlete_listorcoach_list%}There are some athletes or some coaches.
{%endif%}{%ifnotathlete_listorcoach_list%}There are no athletes or there are some coaches (OK, sowriting English translations of boolean logic soundsstupid; it's not our fault).
{%endif%}{%ifathlete_listandnotcoach_list%}There are some athletes and absolutely no coaches.
{%endif%}
{%ifathlete_listandcoach_listorcheerleader_list%}
if(athlete_listandcoach_list)orcheerleader_list
{%ifsomevar=="x"%}This appears if variable somevar equals the string "x"
{%endif%}
{%ifsomevar!="x"%}This appears if variable somevar does not equal the string "x",or if somevar is not found in the context
{%endif%}
{%ifsomevar<100%}This appears if variable somevar is less than 100.
{%endif%}
{%ifsomevar>0%}This appears if variable somevar is greater than 0.
{%endif%}
{%ifsomevar<&#61;100%}This appears if variable somevar is less than 100 or equal to 100.
{%endif%}
{%ifsomevar>&#61;1%}This appears if variable somevar is greater than 1 or equal to 1.
{%endif%}
{%if"bc"in"abcdef"%}This appears since "bc" is a substring of "abcdef"
{%endif%}{%if"hello"ingreetings%}If greetings is a list or set, one element of which is the string"hello", this will appear.
{%endif%}{%ifuserinusers%}If users is a QuerySet, this will appear if user is aninstance that belongs to the QuerySet.
{%endif%}
{%ifa>b>c%} (错误的&#xff09;
{%ifa>bandb>c%}
{%ifmessages|length>&#61;100%}You have lots of messages today!
{%endif%}