时间:2023-06-11 16:30:01 | 来源:网站运营
时间:2023-06-11 16:30:01 来源:网站运营
Python Web开发30-django 模板-HTML转义:因篇幅太多了,往期整理的29篇资料在最后哦
小于号< 转换为<大于号> 转换为>单引号' 转换为'双引号" 转换为 "与符号& 转换为 &
def zhuanyi(request): context={'content':'<h1>hello world</h1>'} return render(request,'booktest/zhuanyi.html',context)
url(r'^zhuanyi/$', views.zhuanyi),
<html><head> <title>转义</title></head><body>自动转义:{{content}}</body></html>
http://127.0.0.1:8000/zhuanyi/
{{t1|escape}}
{{data|safe}}
<html><head> <title>转义</title></head><body>自动转义:{{content}}<hr>过滤器safe关闭转义:{{content|safe}}</body></html>
{%autoescape off%}...{%endautoescape%}
<html><head> <title>转义</title></head><body>自动转义:{{content}}<hr>过滤器safe关闭转义:{{content|safe}}<hr>标签autoescape关闭转义:{%autoescape off%}{{content}}{%endautoescape%}</body></html>
<html><head> <title>转义</title></head><body>自动转义:{{content}}<hr>过滤器safe关闭转义:{{content|safe}}<hr>标签autoescape关闭转义:{%autoescape off%}{{content}}{%endautoescape%}<hr>模板硬编码不转义:{{data|default:'<b>hello</b>'}}</body></html>
<html><head> <title>转义</title></head><body>自动转义:{{content}}<hr>过滤器safe关闭转义:{{content|safe}}<hr>标签autoescape关闭转义:{%autoescape off%}{{content}}{%endautoescape%}<hr>模板硬编码不转义:{{data|default:'<b>hello</b>'}}<hr>模板硬编码手动转义:{{data|default:"<b>123</b>"}}</body></html>
01-四喜Clion:Python Web开发-django搭建环境
02-四喜Clion:Python Web开发02-django创建图书管理项目
03-四喜Clion:Python Web开发03-django模型设计
04-四喜Clion:Python Web开发04-django后台管理
05-四喜Clion:Python Web开发05-django视图
06-四喜Clion:Python Web开发06-django模板
07-四喜Clion:Python Web开发07-django项目完成
08-四喜Clion:Python Web开发08-django ORM简介
09-四喜Clion:Python Web开发09-django ORM-定义模型类
10-四喜Clion:Python Web开发10-django ORM-模型成员
11-四喜Clion:Python Web开发11-django ORM-查询集
12-四喜Clion:Python Web开发12-django ORM-条件查询
13-四喜Clion:Python Web开发13-django ORM-关联的查询
14-四喜Clion:Python Web开发14-django 视图
15-四喜Clion:Python Web开发15-django 视图-URLconf
16-四喜Clion:Python Web开发16-django 视图-内置错误视图
17-四喜Clion:Python Web开发17-django 视图-HttpReqeust对象
18-四喜Clion:Python Web开发18-django 视图-QueryDict对象、GET属性、POST属性
19-四喜Clion:Python Web开发19-django 视图HttpResponse对象
20-四喜Clion:Python Web开发20-django 视图 子类JsonResponse
21-四喜Clion:Python Web开发21-django 视图 子类HttpResponseRedirect
22-四喜Clion:Python Web开发22-django 视图-状态保持
23-四喜Clion:Python Web开发23-django 模板
24-四喜Clion:Python Web开发24-django 模板语言-变量
25-四喜Clion:Python Web开发25-django 模板语言-标签
26-四喜Clion:Python Web开发26-django 模板语言-过滤器
27-四喜Clion:Python Web开发27-django 模板语言-自定义过滤器
28-四喜Clion:Python Web开发28-django 模板语言-注释
29-四喜Clion:Python Web开发29-django 模板-模板继承
关键词:模板