django后端直接更新数据库, 像实体类一样直接更新
程序员文章站
2024-03-24 11:28:28
...
def updatexxxs(request):
"""更新信息"""
systemDict = {}
for key in request.POST:
systemDict[key] = request.POST.get(key)
print(systemDict)
try:
Employee.objects.filter(username=systemDict['username']).update(**systemDict)
data = {
"code": 200,
"msg": '更新成功'
}
resp = JsonResponse(data)
return resp
except:
data = {
"code": 400,
"msg": '更新失败'
}
resp = JsonResponse(data)
return resp