title: Django Rest Framework is it possible to serialize a geojson from a query using a geometry_field via foreignkey?
body: <p>I have two models: one to maintain a grid of points and a second one to save geospatial data</p>
  
  <pre><code>from django.contrib.gis.db import models as geomodels
  from django.db import models
  
  class Grid(geomodels.Model):
  
      geom = geomodels.PointField(srid=4326, unique=True)
      elevation = geomodels.FloatField(blank=True, null=True)
  
  class SpData(models.Model):
  
      mtime = models.DateTimeField()
      grid = models.ForeignKey(Grid)
      measure = models.DecimalField(
          max_digits=6,
          decimal_places=1,
          blank=True,
          null=True,
      )
  </code></pre>
  
  <p>With django rest framework it's very easy to get a geojson file for a model
  having a geometry field as my Grid model, and the following view provide a 
  nice geojson with geom as geometry field and 'elevation' in properties.</p>
  
  <pre><code>from django.http import HttpResponse
  from django.core.serializers import serialize
  from rest_framework.views import APIView
  from .models import Grid
  
  class GridView(APIView):
  
      def get(self, request):
          result = serialize(
              "geojson",
              Grid.objects.all(),
              geometry_field="geom",
              srid=4326,
              fields=(
                  "elevation",
              ),
          )
  
          return HttpResponse(result)
  </code></pre>
  
  <p>Now I want to use the same grid to display the SpData records that are linked to 
  my Grid model to display the 'measure' value, but I do not succeed to indicate 
  to the serializer that I want to use the geometry of the Grid table. I thought 
  that such elegant code could work:</p>
  
  <pre><code>class SpDataView(APIView):
  
      def get(self, request):
          geodata = SpData.objects.filter(mtime=today())
          fields = ("measure", "grid",)
          result = serialize(
              "geojson",
              geodata,
              geometry_field="grid.geom",
              srid=4326,
              fields=fields,
              use_natural_foreign_keys=True,
          )
  
          return HttpResponse(result)
  </code></pre>
  
  <p>But it does not. So, I've tried to add a property field to my SpData model but it does not work either:</p>
  
  <pre><code>class SpData(models.Model):
  
      mtime = models.DateTimeField()
      grid = models.ForeignKey(Grid)
      measure = models.DecimalField(
          max_digits=6,
          decimal_places=1,
          blank=True,
          null=True,
      )
  
      @property
      def geom(self):
          return self.grid.geom
  
  
  class SpDataView(APIView):
  
      def get(self, request):
          geodata = SpData.objects.filter(mtime=today())
          fields = ("measure", "geom",)
          result = serialize(
              "geojson",
              geodata,
              geometry_field="geom",
              srid=4326,
              fields=fields,
          )
  
          return HttpResponse(result)
  </code></pre>
  
  <p>I've tried to use a raw SQL query, but serializer only consider fields of the 
  model on which the raw sql has been done.</p>
  
  <pre><code>strsql ='SELECT sp.pk, sp.measure, g.geom '
  strsql += ' FROM SpData AS sp'
  strsql += ' INNER JOIN Grid AS g'
  strsql += ' ON sp.grid = g.pk'
  strsql += ' WHERE sp.mtime = today()'
  
  geodata = SpData.objects.raw(strsql)
  fields = ("measure", "geom",)
  result = serialize(
      "geojson",
      geodata,
      geometry_field="geom",
      srid=4326,
      fields=fields,
  )
  
  return HttpResponse(result)
  </code></pre>
  
  <p>But geometry in my resulting geojson is equal to null. So reverting the SQL will 
  provide a geometry but will not add the field 'measure' into properties:</p>
  
  <pre><code>strsql ='SELECT g.pk, sp.measure, g.geom '
  strsql += ' FROM Grid AS g'
  strsql += ' INNER JOIN SpData AS sp'
  strsql += ' ON sp.grid = g.pk'
  strsql += ' WHERE sp.mtime = today()'
  
  geodata = Grid.objects.raw(strsql)
  </code></pre>
  
  <p>What am I missing? Is this out of scope of the current geodjango serializer?</p>