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