Пример #1
0
 def post(self, request):
     serializer_data = quoteSerializer(data=request.data)
     if serializer_data.is_valid():
         serializer_data.save()
         return Response(serializer_data.data, status=status.HTTP_200_OK)
     else:
         return Response(serializer_data,
                         status=status.HTTP_400_BAD_REQUEST)
Пример #2
0
 def put(self, request, pk):
     existing_data = QuoteModel.objects.get(id=pk)
     d = request.data
     serializer_data = quoteSerializer(existing_data, data=d)
     if serializer_data.is_valid():
         serializer_data.save()
         content = {'message': 'data inserted'}
         return Response(content, status=status.HTTP_200_OK)
     else:
         return Response(serializer.errors,
                         status=status.HTTP_400_BAD_REQUEST)
Пример #3
0
 def get(self, request, pk):
     xyz = QuoteModel.objects.filter(id=pk)
     serializer = quoteSerializer(xyz, many=True)
     return Response(serializer.data)
Пример #4
0
 def get(self, request):
     xyz = QuoteModel.objects.all()
     serializer = quoteSerializer(xyz, many=True)
     return Response(serializer.data)