title: Django Rest Framework : ForeignKey with Serializer
body: <p>I've two simples table, with a foreignKey. I want to retreive datas in the table with the foreignkey : </p>
  
  <pre><code>CREATE TABLE `firerisk_reminder` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `name` longtext NOT NULL,
    PRIMARY KEY (`id`),
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
  CREATE TABLE `firerisk_remindertype` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(45) NOT NULL,
    `reminder_id` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `name` (`name`),
    KEY `firerisk_remindertyp_reminder_id_03340ffc_fk_firerisk_` (`reminder_id`),
    CONSTRAINT `firerisk_remindertyp_reminder_id_03340ffc_fk_firerisk_` FOREIGN KEY (`reminder_id`) REFERENCES `firerisk_reminder` (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  
  <p>And, so, my model in django : </p>
  
  <pre><code>class Reminder(models.Model):
      name = models.TextField(default='')
      report = models.OneToOneField(Report, related_name='reminder', on_delete=models.PROTECT)
  
      def __str__(self):
          return self.name
  
  class ReminderType(models.Model):
      name = models.CharField(max_length=45, unique=True)
      reminder = models.ForeignKey(Reminder,related_name='reminderstype',on_delete=models.PROTECT)
  </code></pre>
  
  <p>In DRF, I'm using serializers like this : </p>
  
  <pre><code>class ReminderTypeSerializer(serializers.ModelSerializer):
      id = serializers.IntegerField(read_only=True)
      name = serializers.CharField()
  
      class Meta:
          model = ReminderType
          fields = ('id', 'name')
          ordering = ('name',)
  
  class ReminderSerializer(serializers.ModelSerializer):
      remindertypes = ReminderTypeSerializer(read_only=True)
      id = serializers.IntegerField(read_only=True)
      name = serializers.CharField()
  
      class Meta:
          model = Reminder
          ordering = ('name',)
          fields = ('id', 'name', 'remindertypes')
  </code></pre>
  
  <p>Finally, my ViewSets : </p>
  
  <pre><code>class ReminderTypeViewSet(viewsets.ModelViewSet):
      serializer_class = ReminderTypeSerializer
      queryset = ReminderType.objects.all().order_by('name')
      # Authentification !
      permission_classes = (IsAuthenticated,)
      # Only 'get' method
      http_method_names = ['get']
  
  class ReminderViewSet(viewsets.ModelViewSet):
      serializer_class = ReminderSerializer
      queryset = Reminder.objects.all().order_by('name')
      # Authentification !
      permission_classes = (IsAuthenticated,)
      # Only 'get' method
      http_method_names = ['get']
  </code></pre>
  
  <p>When I reverse the call to serializers, like this : </p>
  
  <pre><code>class ReminderTypeSerializer(serializers.ModelSerializer):
      reminder = ReminderSerializer(read_only=True)
      id = serializers.IntegerField(read_only=True)
      name = serializers.CharField()
  </code></pre>
  
  <p>i've the datas, but the relations has no sense for me (remindertype) : </p>
  
  <pre><code>[
      {
          "id": 1,
          "name": "yyyyyyyy",
          "reminder": {
              "id": 1,
              "name": "First report test"
          }
      },
      {
          "id": 2,
          "name": "xxxxxxxx",
          "reminder": {
              "id": 1,
              "name": "First report test"
          }
      }
  ]
  </code></pre>
  
  <p>I've tested some others relations (nested, related, etc), unsuccessfully.</p>
  
  <p>Can you help me please ?
  Thanks
  F.</p>