Skip to main content

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 geo_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.

Project details


Download files

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

Source Distribution

django-geojson_serializer-0.1.tar.gz (3.4 kB view details)

Uploaded Source

File details

Details for the file django-geojson_serializer-0.1.tar.gz.

File metadata

File hashes

Hashes for django-geojson_serializer-0.1.tar.gz
Algorithm Hash digest
SHA256 c93d1601db9cd21901c35a44c6d5f8e9d555550df2dd48badf04c51a2c29efc6
MD5 c1e08c4a8fab9cf9e842ae4458edb8f4
BLAKE2b-256 744ba4ec84fdba8f3595e92ada7e6fd2fe5df50f91bd3e9028ee0c2a623ac52b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page