如何重写APIView的post
方法?在
我试图像bellow一样重写post方法,但似乎它遗漏了一些东西。在
class CloudServerShutdownAPIView(APIView):
"""
shut down the server
"""
serializer_class = CloudServerShutdownSerializer
def post(self, request):
cloudserver_id = request.data.pop("cloudserver_id")
try:
openstackServerShutdown(server_or_id=cloudserver_id)
except Exception as e:
return Response(data="shut down server fail", status=HTTP_404_NOT_FOUND, exception=e)
如何正确重写post方法?在
编辑
回溯如下:
^{pr2}$
这是因为在成功关闭期间没有发送任何响应
相关问题 更多 >
编程相关推荐