Beispiel #1
0
 def put(self, request, pk, format=None):
     admin= Administrador.objects.get(pk=pk)
     serializer = AdministradorSerializers(admin, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
 def put(self, request, pk, format=None):
     Id = self.get_object(pk)
     serializer = AdministradorSerializers(Id, data = request.data)
     if serializer.is_valid():
         serializer.save()
         datas = serializer.data
         return Response(datas)
     return Response("Error", status=status.HTTP_400_BAD_REQUEST)
 def get(self, request, pk, format=None):
     print("Este es el id: " + pk)
     Id = self.get_object(pk)
     if Id != "No":
         Id = AdministradorSerializers(Id)
         return Response(Id.data)
     return Response("No Existe")
 def post(self, request, format=None):
     serializer = AdministradorSerializers(data = request.data)
     if serializer.is_valid():
         serializer.save()
         datas = serializer.data
         return Response(datas, status=status.HTTP_201_CREATED)
 def get(self, request, format=None):
     queryset = Administrador.objects.filter(delete = False)
     serializer = AdministradorSerializers(queryset, many=True)
     return Response(serializer.data)