def put(self, request, id):
     article = self.get_objects(id)
     serializer = ArticleSerializer(data=request.data)
     if serializer.is_valid():
         serializer.save()
         return Response(serializer.data, status=201)
     return Response(serializer.errors, status=400)
Example #2
0
 def put(self, request, id):
     arti = self.get_objects(id)
     serializer = ArticleSerializer(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_400_BAD_REQUEST)
Example #3
0
 def post(self, request, id):
     arti = self.get_objects(id)
     serializer = ArticleSerializer(arti, data=request.data)
     if not serializer.is_valid():
         return Response({'serializer': serializer.data, 'aricle': arti})
     serializer.save()
     return redirect('Articlelist')
 def post(self, request):
     serializer = ArticleSerializer(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_400_BAD_REQUEST)