django mysql数据显示_django实现简单的数据库内容显示

django实现简单的数据库内容显示,练习的部分代码,简单的实现了效果。晒一下。

from django.http import HttpResponse

import os,sys

sys.path.insert(0,os.path.abspath(os.curdir))

import sqlite3

import settings

from ms.models import Student

from django.shortcuts import HttpResponseRedirect,Http404,HttpResponse,render_to_response

def archive(request):

names = Student.objects.all()

return render_to_response("index.html",locals())

django实现简单的数据库内容显示:index.html

Upload Successfully

所在城市

{% for name in names %}

{{name.city}}

1

{{name.name}}

{% endfor %}

玩蛇网文章,转载请注明出处和文章网址:https://www.iplaypy.com/code/other/o2140.html

相关文章 Recommend


版权声明:本文为weixin_35515918原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。