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)
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)
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 get(self, request, id): article = self.get_objects(id) serializer = ArticleSerializer(article) return Response(serializer.data)
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)
def get(self, request): article = Article.objects.all() serializer = ArticleSerializer(article, many=True) return Response({'Article': article})
def get(self, request, id): arti = self.get_objects(id) serializer = ArticleSerializer(arti) return Response({'serializer': serializer.data, 'aricle': arti})