title: string indices must be integers django rest framework
body: <p>I have a big serialized <code>json</code> field from which I'm trying to extract multiple keys then construct another <code>json</code> and send that via requests.</p>
  
  <p>Example:</p>
  
  <pre><code>class ACtionViewSet(viewsets.ModelViewSet):
      logger = logging.getLogger('django')
  
      """
      API endpoint
      """
      queryset = Action.objects.all()
      serializer_class = ActionSerializer
      filter_backends = (filters.OrderingFilter,
                         filters.SearchFilter, DjangoFilterBackend)
      filterset_class = ActionFilter
  
      # create new action for this workflow
      def create(self, request, *args, **kwargs):
          serializer = ActionSerializer(data=request.data, context={'request': request})
          if serializer.is_valid():
              serializer.save()
              encode_data = json.dumps(serializer.data)
              wanted_key = ['task', 'task_default', 'slug']
              new_action = {x: encode_data[x] for x in wanted_key if x in encode_data}
              print(new_action)
              workflow = json.dumps(new_action)
              response = requests.post(
                  url='{}/workflows'.format(MISTRAL_URL),
                  json=workflow,
                  headers=headers
              )
              # logging.debug(f"{self.response}")
              return Response({'response': response}, status=status.HTTP_200_OK)
          return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>The error is</p>
  
  <p><code>string indices must be integers</code></p>
  
  <p>Traceback:</p>
  
  <pre><code>File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
    34.             response = get_response(request)
  
  File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
    126.                 response = self.process_exception_by_middleware(e, request)
  
  File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
    124.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
  File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
    54.         return view_func(*args, **kwargs)
  
  File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/rest_framework/viewsets.py" in view
    116.             return self.dispatch(request, *args, **kwargs)
  
  File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
    495.             response = self.handle_exception(exc)
  
  File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
    455.             self.raise_uncaught_exception(exc)
  
  File "/home/copser/.local/share/virtualenvs/api-IztWJwuB/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
    492.             response = handler(request, *args, **kwargs)
  
  File "/home/copser/Documents/Project/api/src/action/views.py" in create
    76.             new_workflow = {x: encode_data[x] for x in wanted_key if x in encode_data}
  
  File "/home/copser/Documents/Project/NjiNN/njinn/api/src/action/views.py" in &lt;dictcomp&gt;
    76.             new_action = {x: encode_data[x] for x in wanted_key if x in encode_data}
  
  Exception Type: TypeError at /api/v1/action
  Exception Value: string indices must be integers
  </code></pre>
  
  <p>I'm a bit confused why is this happening, so can someone please explain what is happening here, thanks</p>