Dimitris Kougioumtzis Blog About technology

Geojson example

Category Django

Posted on May 12, 2018



Geojson example


1
2
3
4
5
6
7
8
9
from django.contrib.gis.serializers import geojson


def get_category_poi(request):
    category = request.GET.get('category')
    poi = Poi.objects.filter(category_id=category)
    g = geojson.Serializer()
    data = g.serialize(poi, geometry_field='geom', fields=('name', 'category'))
    return HttpResponse(data, content_type='application/json')

About

My name is Dimitris Kougioumtzis and i work as a Web developer at Rapidbounce Company

Elsewhere