GeoJSON Serializer

    The geojson serializer is not meant for round-tripping data, as it has no deserializer equivalent. For example, you cannot use to reload the output produced by this serializer. If you plan to reload the outputted data, use the plain json serializer instead.

    • geometry_field: A string containing the name of a geometry field to use for the geometry key of the GeoJSON feature. This is only needed when you have a model with more than one geometry field and you don’t want to use the first defined geometry field (by default, the first geometry field is picked).
    • srid: The SRID to use for the geometry content. Defaults to 4326 (WGS 84).

    The option can be used to limit fields that will be present in the key, as it works with all other serializers.

    将会输出:

    1. {
    2. 'type': 'FeatureCollection',
    3. 'crs': {
    4. 'type': 'name',
    5. },
    6. 'features': [
    7. {
    8. 'type': 'Feature',
    9. 'geometry': {
    10. },
    11. 'properties': {
    12. 'name': 'Chicago'
    13. }
    14. }
    15. ]