1、增:
models.GameRoom.objects.create(owner=userName, gameStatus=False)
2、查(有两种,get查不到会报错,filter是拿到一个字典集合):
gameListObject = models.GamerList.objects.get(name=userName)
gameListObject = models.GamerList.objects.filter(name=userName)
if gameListObject.count() == 1:
return HttpResponse(json.dumps(response_data), content_type="application/json")
else :
models.GamerList.objects.create(name=userName, status='live', turns=False, owner=False)
return HttpResponse(json.dumps(response_data), content_type="application/json")
3、改:
models.GameRoom.objects.filter(owner=userName).update(status=True, count=9, rand=rand)
4、删:
models.User.objects.filter(name='monkey').delete()
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/4974.html