Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > Python网站web

django将数组传递给前台模板的方法

来源:中文源码网    浏览:154 次    日期:2024-05-07 21:06:23
【下载文档:  django将数组传递给前台模板的方法.txt 】


django将数组传递给前台模板的方法
将数组传递给前台模板:
1.
def modifyBtn(req,modifyip):
print modifyip
conn= MySQLdb.connect(
host='localhost',
port = 3306,
user='root',
passwd='1234567',
db ='DEVOPS'
)
cur = conn.cursor()
a = cur.execute("select ip,info,env from machine_info where ip=%s ",[modifyip])
info = cur.fetchall()
print info
print type(info)
return render(req,'cmdb/modifyBtn.html',{'info':info})
2. node2:/django/mysite/news/templates/cmdb#cat modifyBtn.html


运维平台










{% for x in info %}




{% endfor %}







以上这篇django将数组传递给前台模板的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持中文源码网。

相关内容