title: How to write a django-rest-framework serializer / field to merge data from generic relations?
body: <p>I have objects with a generic relation pointing to various other objects, and I need them to be merged (inlined) so the serialized objects look like one whole objects.</p>
  
  <p>E.G:</p>
  
  <pre><code>class Enrollement(models.Model):
      hq = models.ForeignKey(Hq)
      enrollement_date = models.Datetime()
      content_type = models.ForeignKey(ContentType)
      object_id = models.PositiveIntegerField()
      object = generic.GenericForeignKey('content_type', 'object_id')
  
  class Nurse(models.Model):
       hospital = models.ForeignKey(Hospital)
       enrollement = GenericRelation(Enrollement)
  
  class Pilot(models.Model):
       plane = models.ForeignKey(plane)
       enrollement = GenericRelation(Enrollement)
  </code></pre>
  
  <p>When serialized, I'd like to get something like this:</p>
  
  <pre><code>{
      count: 50,
      next: 'http...',
      previous: null,
      results: [
          {
          type: "nurse",
          hq: 'http://url/to/hq-detail/view',
          enrollement_date: '2003-01-01 01:01:01',
          hospital: 'http://url/to/hospital-detail/view'
  
          },
          {
          type: "pilot",
          hq: 'http://url/to/hq-detail/view',
          enrollement_date: '2003-01-01 01:01:01',
          plante: 'http://url/to/plane-detail/view'
  
          },
      ]
  }
  </code></pre>
  
  <p>Can I do it, and if yes, how ?</p>
  
  <p>I can <a href="http://django-rest-framework.org/api-guide/relations.html">nest</a> a generic relation, and I could post process the serilizer.data to obtain what I want, but I'm wondering if there is a better way.</p>