django。快捷方式进口呈现 django。http进口HttpResponse django。render_to_response快捷方式进口呈现 #创建你的观点。 def你好(请求): 返回render_to_response (“hello.html”) >之前
<强>传递数据到html中强>
python代码
#创建你的观点。 # http://weibo.com/lixiaodaoaaa 类人(对象): def __init__(自我,姓名、年龄、性别): self.name=名字 自我。年龄=年龄 自我。=性 def(自我)说: 返回self.name def你好(请求): u_user=人(“狗”,18岁,“男性”) myList=[“sendList html文件”,“上帝”,“god02”) u_content_dic={" u_title”:“标题在这里”,“u_user”: u_user,“u_test_str”: myList} # #传递一个字典作为Content_type 返回render_to_response(“你好。html”, u_content_dic)<强> Html代码去取值:强>
& lt; !DOCTYPE HTML公共”——//W3C//DTD HTML 4.01过渡//EN” “http://www.w3.org/TR/html4/loose.dtd”在 & lt; html> & lt; head> & lt; title> {{u_title}} & lt;/title> & lt; h2> {{u_user。年龄}}& lt;/h2> & lt; h2> {{u_user.name}} & lt;/h2> & lt; h2> {{u_user.sex}} & lt;/h2> & lt; h2> {{u_test_str.0}} & lt;/h2> & lt; h2> {{u_test_str.1}} & lt;/h2> & lt; br/比; & lt; h2> {{u_user.say}} & lt;/h2> & lt;/head> & lt; body> & lt;/body> & lt;/html> >之前以上这篇django加载本地html的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。
django加载本地html的方法