Exemplo n.º 1
0
 def post(self, request, format=None):
     serializer = AlumnosSerializer(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)
Exemplo n.º 2
0
 def put(self, request, id, format=None):
     example = self.get_object(id)
     if example != False:
         serializer = AlumnosSerializer(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)
Exemplo n.º 3
0
 def get(self, request, id, format=None):
     example = self.get_object(id)
     if example != False:
         serializer = AlumnosSerializer(example)
         return Response(serializer.data)
     else:
         return Response(status=status.HTTP_400_BAD_REQUEST)
Exemplo n.º 4
0
 def get(self, request, format=None):
     queryset = Alumnos.objects.all()
     serializer = AlumnosSerializer(queryset, many=True)
     return Response(serializer.data)
Exemplo n.º 5
0
 def get(self, request, carrera1, format=None):
     queryset = Alumnos.objects.filter(carrera_id=carrera1)
     serializer = AlumnosSerializer(queryset, many=True)
     return Response(serializer.data)
Exemplo n.º 6
0
 def get(self, request, edad1, format=None):
     queryset = Alumnos.objects.filter(edad=edad1)
     serializer = AlumnosSerializer(queryset, many=True)
     return Response(serializer.data)