title: Django REST Framework: nested relationship, how to submit json?
body: <p>I'm using Django 2.1, DRF 3.7.7.<br>
  I've some models and their relative (model) serializers: these models are nested, and so are the serializers.
  Let me give an example:</p>
  
  <pre><code># models.py
  class City(models.Model):
      name = models.CharField(max_length=50)
  
  class Person(models.Model):
      surname = models.CharField(max_length=30)
      birth_place = models.ForeignKey(City)
  
  
  # serializers.py
  class CitySerializer(serializers.ModelSerializer):
      class Meta:
          model = models.CitySerializer
          fields = "__all__"
  
  class PersonSerializer(serializers.ModelSerializer):
      birth_place = CitySerializer()
  
      class Meta:
          model = models.Person
          fields = "__all__"
  </code></pre>
  
  <p>If I submit an AJAX request with a json like:<br>
  <code>{'surname': 'smith', 'birth_place': 42}</code><br>
  I get back a <code>Bad Request</code> response, containing: <code>Invalid data. Expected a dictionary, but got int.</code></p>
  
  <p>If I submit a nested json like:<br>
  <code>{'surname': 'smith', 'birth_place': {'id': 42, 'name': 'Toronto'}}</code><br>
  the relation is not converted, the id field is ignored and the rest is parsed to:<br>
  <code>OrderedDict([('birth_place', OrderedDict([('name', 'Toronto')]))])</code></p>
  
  <p>The following is the post method I'm using on a class-based view:</p>
  
  <pre><code>def post(self, request):
      print("Original data:", request.data)
      serializer = self.serializer_class(data=request.data)
      if serializer.is_valid():
          self.data = serializer.validated_data
          print("Parsed data:", self.data)
          ...
  </code></pre>
  
  <p>I only need to get data from the endpoints connected to the serializers, <strong>I don't need to write/save anything</strong> through the REST interface, since the POST processing of the form is done by Django.</p>
  
  <p><strong>TL;DR</strong>: How should I correctly submit a JSON request to a nested serializer, without having to write handmade conversions? Did I commit errors in setting up the serializers?</p>
  
  <p><strong>Edit</strong>: I've discovered that by adding <code>id = serializers.IntegerField()</code> to the serializer parent class (e.g. City), the serializer parser now processes the id. At least now I'm able to perform actions in the backend with django.</p>