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