title: How change JSON response result in POST request | DRF?
body: <p>I am little bit confused and need some advise how correctly organize view. In my Django REST Framework project I have pretty simple model and serializer.</p>
  
  <p><strong>models.py</strong>:</p>
  
  <pre><code>class Article(models.Model):
      body = models.TextField()
  </code></pre>
  
  <p><strong>serializers.py</strong>:</p>
  
  <pre><code>class ArticleSerializer(serializers.ModelSerializer):
      class Meta:
          model = Article
          fields = ('id', 'body')
  </code></pre>
  
  <p>Lets say I have next data in database:</p>
  
  <pre><code>ID | BODY
  -------------------------------------------------------------
  1  | Aki doing his homework about japanese robot in library.
  2  | All chapters are accompanied by necessary links.
  3  | Japanese robot Aki doing a lot of tasks.
  </code></pre>
  
  <p>Right now I try to send <code>JSON</code> by <code>POST</code> request to <code>ArticleFilterView</code> controller:</p>
  
  <pre><code>curl -X POST -H "Content-Type: application/json" -d '[
  {
      "first": ["Aki", "robot"], 
      "second": ["doing", "library"]
  }]'
  
  http://localhost:8000/api/article/filter/
  </code></pre>
  
  <p>If any article has words "Aki" and "robot" in body field, I want to add that article to JSON response. In the same time I need to remove "doing" and "library" words from the text.</p>
  
  <p><strong>Input:</strong></p>
  
  <pre><code>[{
      "fisrt": ["Aki", "robot"], 
      "second": ["doing", "library"]
  }]
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>[
  {"id": 1, "body": "Aki his homework about japanese robot in ."},
  {"id": 3, "body": "Japanese robot Aki a lot of tasks."},
  ]
  </code></pre>
  
  <p><strong>views.py:</strong></p>
  
  <pre><code>class ArticleFilterView(APIView):
      parser_classes = (JSONParser,)
  
      def post(self, request, format=None):
          # some code
          return Response({'received data': request.data})
  </code></pre>
  
  <p><strong>settings.py:</strong></p>
  
  <pre><code>REST_FRAMEWORK = {
      'DEFAULT_RENDERER_CLASSES': (
          'rest_framework.renderers.JSONRenderer',
      ),
      'DEFAULT_PARSER_CLASSES': (
          'rest_framework.parsers.JSONParser',
      ),
      'DEFAULT_PERMISSION_CLASSES': (
          'rest_framework.permissions.AllowAny',
      ),
  }
  </code></pre>
  
  <p><strong>urls.py:</strong> (in the same directory where is <code>settings.py</code> file)</p>
  
  <pre><code>urlpatterns = [
      path('api/', include('article.urls')),
  ]
  </code></pre>
  
  <p><strong>article/urls.py:</strong></p>
  
  <pre><code>urlpatterns = [
      path(
          'article/filter/',
          ArticleFilterView.as_view(),
          name='article_filter',
      ),
  ]
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qLvt5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qLvt5.jpg" alt="enter image description here"></a></p>