title: How to create a new OneToOne object in another's model Serializer?
body: <p>I have 2 models: <code>Content</code> and <code>Address</code>. Each content has one address so the models are something like this:</p>
  <pre><code>class Content(models.Model):
     ....
  
  class Address(model.Model):
     content = OneToOneField(Content)
     ....
  </code></pre>
  <p>I now want to adjust the <code>ContentSerializer</code> so that I can pass data for an address in it.</p>
  <pre><code>class Content(serializers.ModelSerializer):
      address = ContentAddressSerializer()
  
      class Meta:
          model = Content
          fields = ('address')
  
      def create(self, validated_data):
          if &quot;address&quot; in validated_data:
              address = validated_data.pop('address')
              Address.objects.create(**address)
          validated_data['editor'] = self.context['request'].user
          return Content.objects.create(**validated_data)
  </code></pre>
  <p>I'm succesfully creating an <code>Address</code> but when the <code>to_represantation</code> method is called, I get an <code>AttributeError</code>. Is there a better and easier way than to override the <code>to_representation</code> method?</p>