当前第2页 返回上一页
business函数
1 2 3 4 5 | def business(request):
v1 = models.Business.objects.all()
v2 = models.Business.objects.all().values( "id" , "caption" )
v3 = models.Business.objects.all().values_list( 'id' , 'caption' )
return render(request, "business.html" ,{ "v1" :v1, "v2" :v2, "v3" :v3})
|
1 | url(r '^business$' ,views.business)
|
business.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <!DOCTYPE html>
<html lang= "en" >
<head>
<meta charset= "UTF-8" >
<title>Document</title>
</head>
<body>
<ul>
<h1>ALL</h1>
{% for row in v1 %}
<li>{{row.id}}-{{row.caption}}-{{row.code}}</li>
{% endfor %}
</ul>
<ul>
<h1>all.values</h1>
{% for row in v2 %}
<li>{{row.id}}-{{row.caption}}</li>
{% endfor %}
</ul>
<ul>
<h1>all.values_list</h1>
{% for row in v3 %}
<li>{{row.0}}-{{row.1}}</li>
{% endfor %}
</ul>
</body>
</html>
|
以上就是Django数据库增删改查操作的实例的详细内容,更多文章请关注木庄网络博客!!
返回前面的内容
相关阅读 >>
如何进行数据库连接?(实例解析)
Python中有栈吗
Python中排序算法的实现方法总结(代码)
Python3哪个版本稳定
c和Python的区别
Python中的super函数如何实现继承?
Python gpu 什么意思
Python 装饰器详解
Python中count函数的用法
Python的idle打不开怎么办
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » Django数据库增删改查操作的实例