Python全系列 教程
3567个小节阅读:5931.3k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
布尔运算符
and、or和not
xxxxxxxxxx
{% if athlete_list and coach_list %}
Both athletes and coaches are available.
{% endif %}
{% if not athlete_list %}
There are no athletes.
{% endif %}
{% if athlete_list or coach_list %}
There are some athletes or some coaches.
{% endif %}
{% if not athlete_list or coach_list %}
There are no athletes or there are some coaches.
{% endif %}
{% if athlete_list and not coach_list %}
There are some athletes and absolutely no coaches.
{% endif %}
允许在同一个标签中使用两个and和or子句, and优先级高于or例如:
xxxxxxxxxx
{% if athlete_list and coach_list or cheerleader_list %}
将被解释为:
if (athlete_list and coach_list) or cheerleader_list
但是在if标签中使用实际的括号是无效的语法。如果你需要它们来表示优先级,你应该使用嵌套if标签
逻辑运算符
==, !=, <, >, <=, >=, in, not in, is, 和 is not
xxxxxxxxxx
{% if somevar == "x" %}
This appears if variable somevar equals the string "x"
{% endif %}
{% if "bc" in "abcdef" %}
This appears since "bc" is a substring of "abcdef"
{% endif %}
{% if somevar is not True %}
This appears if somevar is not True, or if somevar is not found in the
context.
{% endif %}
优先级,从低到高:
url
给定视图和可选参数匹配的绝对路径引用(没有域名的URL)
xxxxxxxxxx
{% url 'some-url-name' v1 v2 %}
第一个参数是url模式名称,后面跟着的是参数,以空格分隔
可以使用关键字:
{% url 'some-url-name' arg1=v1 arg2=v2 %}
如果您想检索命名空间的URL,请指定完全限定的名称:
{% url 'myapp:view-name' %}