예제 #1
0
    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)
예제 #2
0
 def destroy(self, request, pk=None):
     data = "DELETE"
     return api(self.code, data)
예제 #3
0
 def partial_update(self, request, pk=None):
     data = "PATCH"
     return api(self.code, data)
예제 #4
0
 def update(self, request, pk=None):
     data = "PUT"
     return api(self.code, data)
예제 #5
0
 def retrieve(self, request, pk=None):
     data = "GET"
     return api(self.code, data)
예제 #6
0
 def list(self, request):
     data = ['Hello', 'World']
     return api(self.code, data)
예제 #7
0
 def patch(self, request, pk=None):
     data = "PATCH"
     return api(self.code, data)