Geojson example

Django -- Posted on May 12, 2018

Geojson example

              
                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')
                  
   
            

Related Posts