1688网站建设方案书模板,如何制作自己的网站和app,深圳网站定制建设,婚纱摄影影楼将views.py中的变量传递给html模板来显示#xff0c;变量是以字典的形式传递给html模板文件显示的。 模板文件里以字典的{{健名}}来得到健值。 可传递的变量有以下几种形式 1. 基本变量 return render_to_response(index.html, {title:title-django, user:user-django}) 2. 字… 将views.py中的变量传递给html模板来显示变量是以字典的形式传递给html模板文件显示的。 模板文件里以字典的{{健名}}来得到健值。 可传递的变量有以下几种形式 1. 基本变量 return render_to_response(index.html, {title:title-django, user:user-django}) 2. 字典 usr {name:zhang, age:32, sex:male} return render_to_response(index.html, {zidian:usr}) 在html模板文件中{{zidian}}将输出字典的全部内容也可以{{zidian.name}}分别输出字典的某一个健值 3. 类 class Person(object): def __init__(self,name,age,sex): self.name name self.age age self.sex sex usr Person(li, 30, male) return render_to_response(index.html, {duixiang:usr}) 在html模板文件中{{duixiang.name}}将输出对象的属性值 4. 列表 mylist [aaa‘, bbb] return render_to_response(index.html, {list:mylist}) 在html模板文件中{{list}}将输出列表中的所有数据也可以{{list.0}}来输出列表中的某一项