###
from 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‘)
###
时间: 2024-10-31 21:31:58