def post(self, request, format=None): serializer = ExampleSerializers(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 != 404: serializer = ExampleSerializers(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 = ExampleSerializers(example) return Response(serializer.data) else: return Response(status=status.HTTP_400_BAD_REQUEST)
def get(self, request, id, format=None): example = self.get_object(id) if example != 404: serializer = ExampleSerializers(example) return Response(serializer.data) else: return Response(example)
def get(self, request, id, format=None): example = self.get_object(id) if example != 404: #many = True, no aplica si se retorna solo un objeto serializer = ExampleSerializers(example) return Response(serializer.data) else: return Response(example, status=status.HTTP_400_BAD_REQUEST)
def get(self, request, id, format=None): example = self.get_object(id) if example != 404: #many = True No aplica si retorno un solo objeto serializer = ExampleSerializers(example) return Response(serializer.data) else: return Response(example)
def get(self, request, format=None): queryset = Example.objects.filter( delete=False) #id.example2 = id.example #many = True, si aplica si se retorna varios objetos serializer = ExampleSerializers(queryset, many=True) return Response(serializer.data)
def get(self, request, format=None): queryset = Example.objects.filter(delete=False) serializer = ExampleSerializers(queryset, many=True) return Response(serializer.data)
def get(self, request, format=None): print("Metodo get filter") queryset = Example.objects.filter(delete = False) #many = True Si aplica si retorno multiples objetos serializer = ExampleSerializers(queryset, many=True) return Response(serializer.data)