验证实例:
class UserInfoSerializer(serializers.Serializer): title = serializer.CharField(error_messages={'required':'标题不能为空'}) class UserInfoView(APIView): def post(self,request,*args,**kwargs): ser = UserInfoSerializer(data=request.data) if ser.is_vaild(): print(ser.vaildated_data['title']) else: print(ser.errors) return HttpResponse('提交数据')