Skip to main content
Help us improve Python packaging – donate today!

Geojson serializer decorator for django rest framework

Project Description

DRF geojson serializer is a decorator which allows to format data as geojson http://geojson.org

Quick start

Geojson serializer works with django rest framework as a decorator.

  1. Add django-geojson_serializer to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
    ....
    'django-geojson_serializer'
    ]
    
  2. In your code you can use geojson_serializer(<name-of-geo-field>) decorator with a regualar serializer, e.g.:

    from geojson_serializer.serializers import geojson_serializer
    
    
    class City(models.Model):
        name = models.CharField(max_length=128)
        location = models.PointField()
    
    
    @geojson_serializer('location')
    class CitySerializer(serializers.ModelSerializer):
        class Meta:
            model = City
            fields =['name', 'location']
    
    
    class CityViewSet(viewsets.ModelViewSet):
        queryset = City.objects.all()
        serializer_class = CitySerializer
    

Then you can register CityViewSet with a router and the view will generate and accept geojsons in corresponding requests.

Release history Release notifications

This version
History Node

0.2

History Node

0.1.1

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-geojson_serializer-0.2.tar.gz (3.4 kB) Copy SHA256 hash SHA256 Source None Apr 24, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page