class LoginPwdSerializer(serializers.Serializer):mobile = serializers.CharField(required=True, validators=[RegexValidator(r"\d{11}", message="格式错误")])password = serializers.CharField(required=True)def validate_mobile(self, value):exists = models.Company.objects.filter(mobile=value).exists()if not exists:raise ValidationError("手机号不存在")return valuedef validate_password(self, value):return md5(value)class LoginPwdView(BaseView, APIView):def post(self, request):ser = LoginPwdSerializer(data=request.data)ser.is_valid(raise_exception=True)print(ser.validated_data)print(ser.initial_data)print(ser.data)# instance = models.Company.objects.filter(**ser.).first()return Response("ok")