Giter Club home page Giter Club logo

django-rest-framework-gis's Introduction

djangorestframework-gis

build status

GeoDjango Tools for Django REST Framework

Author: Mjumbe Wawatu Poe, Follow me on Twitter.

Usage

If you want to render your model as a GeoJSON Feature, use the renderer.

views.py:

from rest_framework.views import APIView
from rest_framework.settings import api_settings
from rest_framework_gis.renderers import GeoJSONRenderer
from rest_framework_gis.parsers import GeoJSONParser

class MyView (APIView):
    renderer_classes = (GeoJSONRenderer, ) + api_settings.DEFAULT_RENDERER_CLASSES
    parser_classes = (GeoJSONParser, ) + api_settings.DEFAULT_PARSER_CLASSES
    ...

In your serializers, use the serializers.GeometryField for your geometry fields (or use the serializers.GeometryModelSerializer, which will use the GeometryField automatically). The GeoJSONRenderer will render geometry fields as GeoJSON geometries.

Also available is the FeatureRenderer, which will render a collection of models with geometries as a GeoJSON feature collection. This renderer assumes a field named 'geometry'. To use a different field name, override the value of the geometry_field_name attribute the renderer or the view.

For more information about using renderers with Django REST Framework, see the API Guide or the Tutorial.

Running the tests

To run the tests against the current environment:

./manage.py test

django-rest-framework-gis's People

Contributors

mjumbewu avatar batpad avatar

Watchers

Govind Sharma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.