---
title: "Penserial GeoJSON"
version: 1.11
locale: id
source: https://docs.djangoproject.com/id/1.11/ref/contrib/gis/serializers/
canonical: https://djangodocs.dev/id/1.11/ref/contrib/gis/serializers/
---
# Penserial `GeoJSON`

GeoDjango menyediakan penserial khusus untuk bentuk [GeoJSON](http://geojson.org/). Lihat [Serializing Django objects](/id/1.11/topics/serialization/) untuk informasi lebih pada serialisasi.

The `geojson` serializer is not meant for round-tripping data, as it has no
deserializer equivalent. For example, you cannot use [`loaddata`](/id/1.11/ref/django-admin/#django-admin-loaddata) to
reload the output produced by this serializer. If you plan to reload the
outputted data, use the plain [json serializer](/id/1.11/topics/serialization/#serialization-formats-json)
instead.

In addition to the options of the `json` serializer, the `geojson`
serializer accepts the following additional option when it is called by
`serializers.serialize()`:

- `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`: SRID digunakan untuk isi `geometry`. Awalan pada 4326 (WGS 84).

The [fields](/id/1.11/topics/serialization/#subset-of-fields) option can be used to limit fields that
will be present in the `properties` key, as it works with all other
serializers.

Contoh:

```
from django.core.serializers import serialize
from my_app.models import City

serialize('geojson', City.objects.all(),
          geometry_field='point',
          fields=('name',))
```

Akan mengeluarkan:

```
{
  'type': 'FeatureCollection',
  'crs': {
    'type': 'name',
    'properties': {'name': 'EPSG:4326'}
  },
  'features': [
    {
      'type': 'Feature',
      'geometry': {
        'type': 'Point',
        'coordinates': [-87.650175, 41.850385]
      },
      'properties': {
        'name': 'Chicago'
      }
    }
  ]
}
```

When the `fields` parameter is not specified, the `geojson` serializer adds
a `pk` key to the `properties` dictionary with the primary key of the
object as the value.

> **Changed in Django 1.10**
>
> Kunci `pk` telah ditambahkan ke kamus `properties`.
