Check if a variable is defined in django templating language [closed]

ⅰ亾dé卋堺 提交于 2019-12-05 06:24:33

Please read the documentation.

The {% if %} tag evaluates a variable, and if that variable is “true” (i.e. exists ...

{% 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 %}

You might also want to check out the rather handy Django tutorial for writing public views.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!