def put(self, request, *args, **kwargs): """全部更新""" pk = kwargs.get('pk') article_object = models.Article.objects.filter(id=pk).first() ser = serializer.FormNewArticleSerializer(instance=article_object, data=request.data) if ser.is_valid(): ser.save() return Response(ser.data) return Response(ser.errors)
def post(self, request, *args, **kwargs): ser = serializer.FormNewArticleSerializer(data=request.data) if ser.is_valid(): ser.save() return Response(ser.data) return Response(ser.errors)