I have a geographical model structure where multiple events can have the same location:
class Event(models.Model):
name = models.CharField(max_length=128, blank=True, null=True)
location = models.ForeignKey('MarketLocation', null=True, blank=True)
class EventLocation(models.Model):
location = models.PointField(srid=4326)
I am using the GeoFeatureModelSerializer
provided by django-rest-framework-gis to output a single JSON object but the PointField
is being rendered as a string instead of a coordinate pair:
So it is giving me:
"location": "POINT (-1.909 53.7094)"
Instead of:
"point": {
"type": "Point",
"coordinates": [-123.0208, 44.0464],
},
The logical answer would be to define the field in the serializer:
geo_field = eventlocation__location
But that doesn't appear to make any difference to the output, which makes me think that it probably doesn't work but it probably should. Has anybody made this work and if so how?