Exemple #1
0
 def post(self, request):
     serializer = GallerySerializer(data=request.DATA)
     if serializer.is_valid():
         serializer.save()
         return Response(status=status.HTTP_201_CREATED)
     else:
         return Response(
             serializer.errors,
             status=status.HTTP_406_NOT_ACCEPTABLE
         )
Exemple #2
0
 def post(self, request, format=None):
     serializer = GallerySerializer(data=request.DATA, partial=True)
     if serializer.is_valid():
         obj = self.get_object(request.DATA['pk'])
         obj.delete()
         return Response(status=status.HTTP_200_OK)
     else:
         return Response(
             serializer.errors,
             status=status.HTTP_406_NOT_ACCEPTABLE
         )