def create(self, request): serializer = self.serializer_class(data=request.data) if serializer.is_valid(): name = serializer.validated_data.get('name') data = f'Hello {name}' else: self.code = status.HTTP_400_BAD_REQUEST data = serializer.errors return api(self.code, data)
def destroy(self, request, pk=None): data = "DELETE" return api(self.code, data)
def partial_update(self, request, pk=None): data = "PATCH" return api(self.code, data)
def update(self, request, pk=None): data = "PUT" return api(self.code, data)
def retrieve(self, request, pk=None): data = "GET" return api(self.code, data)
def list(self, request): data = ['Hello', 'World'] return api(self.code, data)
def patch(self, request, pk=None): data = "PATCH" return api(self.code, data)