def post(self, request, format=None): opere_serializer = OperaSerializer(data=request.data) if opere_serializer.is_valid(): opere_serializer.save() return Response(opere_serializer.data, status=status.HTTP_201_CREATED) return Response(opere_serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def put(self, request, id, format=None): opera = self.get_object(id) print(opera) opera_serializer = OperaSerializer(opera, data=request.data) if opera_serializer.is_valid(): opera_serializer.save() return Response(opera_serializer.data) return Response(opera_serializer.errors, status=status.HTTP_400_BAD_REQUEST)