首页 > 数据库技术 > 详细

再次学习Django,实现sql的页面显示及条件查询

时间:2019-04-23 12:43:46      阅读:229      评论:0      收藏:0      [点我收藏+]
view.py
def search_post(request):
global ctx_2
cursor.execute(‘select * from testdj_test‘)
#ctx = {}
ctx_2 = dictfetchall(cursor)
return render(request, "post.html", {‘results‘: ctx_2})


html
<table class="table">
{% for item in results %}
<tr>
<td>{{item.name}}</td>
<td>{{item.age}}</td>
<td>{{item.course}}</td>
</tr>
{%endfor%}
</table>


再次学习Django,实现sql的页面显示及条件查询

原文:https://www.cnblogs.com/tangbinghaochi/p/10755608.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!