Django #数据库基本的增删改查
时间:2021-07-01 10:21:17
帮助过:22人阅读
django.shortcuts
import render,HttpResponse
from app01
import models
# Create your views here.
def orm(request):
# #创建数据推荐方式:
# models.UserInfo.objects.create(
# username = ‘ljc‘,
# password = ‘1233‘
# )
# #方式2
# # dict1={‘username‘:‘hyr‘,‘password‘:‘666‘}
# # models.UserInfo.objects.create(**dict1)
# #方式3
# # obj = models.UserInfo(username=‘zxt‘,password=‘456‘)
# # obj.save()
#查询
# result = models.UserInfo.objects.all()
# for row in result:
# print(row.id,row.username,row.password)
# result = models.UserInfo.objects.filter(username=‘lws‘,password=‘123‘)
# for row in result:
# print(row.id,row.username,row.password)
#删除
# models.UserInfo.objects.filter(username=‘lws‘).delete()
#修改
# models.UserInfo.objects.all().update(password=‘888888‘)
return HttpResponse(
‘ORM‘)
###
Django #数据库基本的增删改查
标签:pre result views app int models pass blog port