class test(APIView):
def post(self,request):
username = request.data['username']
User.objects.update_or_create(username=username, defaults=request.data)
return APIResponse(msg=123)
update_or_create(**kwargs,defaults={})
kwargs 为查找值,defaults={}为替换值
class test(APIView):
def post(self,request):
username = request.data['username']
User.objects.update_or_create(username=username, defaults=request.data)
return APIResponse(msg=123)
update_or_create(**kwargs,defaults={})
kwargs 为查找值,defaults={}为替换值