def post(self, request, format=None): serializer = InventorySerializer(data=request.data) if serializer.is_valid(): serializer.save() datas = serializer.data return Response(datas) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
def put(self, request, id, format=None): example = self.get_object(id) if example != False: serializer = InventorySerializer(example, data=request.data) if serializer.is_valid(): serializer.save() datas = serializer.data return Response(datas) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) else: return Response(status=status.HTTP_400_BAD_REQUEST)
def get(self, request, id, format=None): example = self.get_object(id) if example != False: serializer = InventorySerializer(example) return Response(serializer.data) else: return Response(status=status.HTTP_400_BAD_REQUEST)
def get(self, request, format=None): queryset = Inventory.objects.all() serializer = InventorySerializer(queryset, many=True) return Response(serializer.data)