小编hit*_*ain的帖子

我在 django 上运行 api 时遇到错误“[Errno 5] 输入/输出错误”

Django API 代码:

def post(self,request)-> JsonResponse:
        try:
            self.email = request.data['email']
            self.mobile = request.data['mobile']
            self.password = request.data['password']
        except Exception as e:
            return JsonResponse(create_failure('400',f"invalid payload {e}","fail"))
        try:
            res = {}
            jwt_token = ''
            if self.email:
                password = Customer.objects.get(email=self.email).password
                username  = Customer.objects.get(email=self.email).username
                print(password)
                if check_password(self.password,password) :
                    jwt_token = make_jwt_token({'username':username})
                else:
                    return JsonResponse(create_failure('500',f"Invalid password","fail"))
            elif self.mobile:
                password = Customer.objects.get(mobile=self.mobile).password
                username  = Customer.objects.get(mobile=self.mobile).username
                if check_password( password,self.password) :
                    jwt_token = make_jwt_token({'username':username})
                else:
                    return JsonResponse(create_failure('500',f"Invalid password","fail"))
            res['token'] = jwt_token
        except Exception as e:
            return JsonResponse(create_failure('400',f"error in verifying …
Run Code Online (Sandbox Code Playgroud)

python linux django cpanel

5
推荐指数
2
解决办法
7162
查看次数

标签 统计

cpanel ×1

django ×1

linux ×1

python ×1