I'm using Django 1.8, with GeoDjango and PostGIS. I am using HttpResponse
to return some GeoJSON:
from django.http import HttpResponse, JsonResponse
code = request.GET.get('q', '')
results = PCT.objects.filter(Q(code__startswith=code) |
Q(name__icontains=code))
results = results.filter(org_type='CCG')
for result in results:
print result.code
geo_field = 'boundary'
fields = ('name', 'code', 'ons_code', 'org_type', 'boundary', )
return HttpResponse(serialize('geojson', results,
geometry_field=geo_field, fields=fields),
content_type='application/json')
In the console this prints a code
field just fine:
99N
But the GeoJSON returned does not have a properties.code
field. It has a properties.name
, properties.org_type
and properties.ons_code
field though.
Why is this? Is code
a reserved name perhaps? If so, how can I fix this?