title: Django Rest Framework, add object to request.data and then call serializer is_valid()
body: <p>I'm wondering which is the best way to solve this, I have a nested serializer like this:</p>
  
  <p>serializers.py:</p>
  
  <pre><code>class PaymentMethodSerializer(serializers.ModelSerializer):
  
      data = serializers.JSONField()
      payment_type = PaymentTypeSerializer(required=False)
  </code></pre>
  
  <p>Then, the view looks something like this:</p>
  
  <pre><code>class PaymentMethodView(APIView):
      def put(self, request, id):
  
          try:
              payment_method = PaymentMethod.objects.get(id=id)
          except ObjectDoesNotExist:
              return Response("No PaymentMethod with that id", status=status.HTTP_404_NOT_FOUND)
  
          payment_method_serialized = PaymentMethodSerializer(instance=payment_method, data=request.data)
          payment_type = request.data.get("payment_type", None)
  
          if payment_type:
              try:
                  payment_method_type = PaymentType.objects.get(id=payment_type)
              except ObjectDoesNotExist:
                  payment_method_type = None
          else:
              payment_method_type = None
  
      # Now, call is_valid()
          if payment_method_serialized.is_valid():
              payment_method_serialized.save(payment_type=payment_method_type)
              return Response(payment_method_serialized.data, status=status.HTTP_200_OK)
  </code></pre>
  
  <p><code>is_valid()</code> returns False and this error:</p>
  
  <pre><code>{"payment_type":{"non_field_errors":["Invalid data. Expected a dictionary, but got int."]}}
  </code></pre>
  
  <p>I understand it, I'm giving the serializer a <code>pk</code>. However I don't want to create a new serializer with a <code>PrimaryKeyRelatedField</code> instead of the nested relationship just for this. How can I get the <code>PaymentType</code> that corresponds to that <code>pk</code> and then add that object to the <code>request.data</code> dictionary so that <code>is_valid</code> doesn't fail? is it the best way to solve this?</p>