from django.shortcuts import rende
return render(request,'模板文件名', 字典数据)
Django 模板语言
模板的传参
模板传参是指把数据形成字典...,传参给模板,为模板渲染提供数据
使用 loader 加载模板
t = loader.get_template('xxx.html')
html = t.render(字典数据)
return HttpResponse...(html)
使用render加载模板
return render(request,'xxx.html',字典数据)
模板的变量
在模板中使用变量语法
{{ 变量名 }}
{{ 变量名.index...=, , =, in, not in, is, is not, not、and、o
在 if 标记中使用实际括号是无效的语法。 如果您需要它们指示优先级,则应使用嵌套的 if 标记。...%}
重写的覆盖规则
不重写,将按照父模板的效果显示
重写,则按照重写效果显示
注意
模板继承时,服务器端的动态内容无法继承
参考文档
https://docs.djangoproject.com/en