#注册
def add_person(request):p_name = request.POST.get("p_name")p_password = request.POST.get("p_password")person_data = {"p_name": p_name,"p_password": p_password,}print(person_data)serializer = PersonSerializer(person_data)if not serializer.is_valid():return JsonResponse(serializer.errors)serializer.save()print("222")data = {"msg": "注册成功","status": status.HTTP_201_CREATED,# "data": serializer.data}return JsonResponse(data)
原因:data=person_data
报错:
'Cannot call `.is_valid()` as no `data=` keyword argument was '
AssertionError: Cannot call `.is_valid()` as no `data=` keyword argument was passed when instantiating the serializer instance.
[17/Oct/2019 17:58:56] "POST /three/addperson/ HTTP/1.1" 500 77619