django将数组传递给前台模板的方法
将数组传递给前台模板:
1.
defmodifyBtn(req,modifyip): printmodifyip conn=MySQLdb.connect( host='localhost', port=3306, user='root', passwd='1234567', db='DEVOPS' ) cur=conn.cursor() a=cur.execute("selectip,info,envfrommachine_infowhereip=%s",[modifyip]) info=cur.fetchall() printinfo printtype(info) returnrender(req,'cmdb/modifyBtn.html',{'info':info})
2.node2:/django/mysite/news/templates/cmdb#catmodifyBtn.html
运维平台 {%forxininfo%} 地址 描述 环境 {%endfor%}
以上这篇django将数组传递给前台模板的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。