8

I'm trying to serialize data in the geojson format however whenever I use

json = serialize("geojson", coordinate.objects.all())
response = HttpResponse(json)
return response

django gives me

SerializerDoesNotExist at /getmarkers/ 'geojson'

this works fine

json = serialize("json", coordinate.objects.all())

surely anyone else who has tried using the geojson serializer has ran into the same issue. I've installed the GDAL library as told to do so in the docs. Any ideas? Can't seem to really find anything in the docs about what modules must be imported I've tried

from django.contrib.gis import gdal

Does not throw an error but also does not fix the issue I'm using Django 1.8

Groovietunes
  • 633
  • 1
  • 9
  • 17

1 Answers1

24

You need to include the geojson serializer in settings.py

SERIALIZATION_MODULES = {
    "geojson": "django.contrib.gis.serializers.geojson", 
 }
CormacMOB
  • 356
  • 2
  • 2
  • 7
    Django should really include this in the [geojson serializer docs](https://docs.djangoproject.com/en/1.11/ref/contrib/gis/serializers/#). If it weren't for this post, I'd still be looking too. – Austin A Jan 23 '18 at 16:31