title: Django Rest Framework Serializer Relations: How to get list of all child objects in parent's serializer?
body: <p>I'm new to DRF and have just started building an API. I have two models, a child model connected to a parent model with a foreign key. Here is the simplified version of the model I have:</p>
  
  <pre><code>class Parent(models.Model):
      name = models.CharField(max_length=50)
  
  
  class Child(models.Model):
      parent = models.ForeignKey(Parent)
      child_name = models.CharField(max_length=80)
  </code></pre>
  
  <p>To create serializers, I followed the <a href="http://www.django-rest-framework.org/api-guide/relations/">DRF Serializer Relations</a> and I've created them as the following:</p>
  
  <pre><code>class ChildSerializer(serializers.HyperlinkedModelSerializer):
  
      parent_id = serializers.PrimaryKeyRelatedField(queryset=Parent.objects.all(),source='parent.id')
  
      class Meta:
          model = Child
          fields = ('url','id','child_name','parent_id')
  
      def create(self, validated_data):
          subject = Child.objects.create(parent=validated_data['parent']['id'], child_name=validated_data['child_name'])
  
          return child
  
  
  class ParentSerializer(serializers.HyperlinkedModelSerializer):
      children = ChildSerializer(many=True, read_only=True)
      class Meta:
          model = Course
          fields = ('url','id','name','children')
  </code></pre>
  
  <p>I'm trying to get the list of all children in parent's serializer. What I want is to be able to get a response like this: </p>
  
  <pre><code>{
      'url': 'https://dummyapidomain.com/parents/1/',  
      'id': '1',
      'name': 'Dummy Parent Name',
      'cildren': [
          {'id': 1, 'child_name': 'Dummy Children I'},
          {'id': 2, 'child_name': 'Dummy Children II'},
          {'id': 3, 'child_name': 'Dummy Children III'},
          ...
      ],
  }
  </code></pre>
  
  <p>I wasn't expecting this to work since there is no link between Parent and Child in the Parent model, <a href="http://www.django-rest-framework.org/api-guide/relations/#nested-relationships">but it is the suggested way to do it in the documentation</a>, and it didn't work.</p>
  
  <p>I'm getting the following error message:</p>
  
  <pre><code>Got AttributeError when attempting to get a value for field `children` on serializer `ParentSerializer`.
  The serializer field might be named incorrectly and not match any attribute or key on the `Parent` instance.
  Original exception text was: 'Parent' object has no attribute 'children'.
  </code></pre>
  
  <p>I think it's perfectly reasonable, but I couldn't understand what I'm missing here. </p>
  
  <p>How can I get the list of all children in parent's serializer?</p>