Пример #1
0
 def put(self, request, pk):
     task = self.get_object(pk)
     serializer = TaskSerializer(instance=task, data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data)
     return Response(serializer.errors)
Пример #2
0
 def post(self, request):
     serializer = TaskSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(serializer.errors,
                     status=status.HTTP_500_INTERNAL_SERVER_ERROR)
Пример #3
0
    def post(self, request, pk):
        tasklist = self.get_object(pk)
        serializer = TaskSerializer(data=request.data)

        if serializer.is_valid():
            serializer.save(task_list=tasklist)
            return Response(serializer.data)
        return Response(serializer.errors)
Пример #4
0
 def get(self, request, pk):
     task = self.get_task(pk)
     serializer = TaskSerializer(task)
     return Response(serializer.data)
Пример #5
0
 def get(self, request, pk):
     tasklist = self.get_object(pk)
     tasks = tasklist.tasks.all()
     serializer = TaskSerializer(tasks, many=True)
     return Response(serializer.data)
Пример #6
0
 def get(self, request):
     tasks = Task.objects.all()
     serializer = TaskSerializer(tasks, many=True)
     return Response(serializer.data, status=status.HTTP_200_OK)