diff options
| author | Samir Shah <solaris.smoke@gmail.com> | 2022-05-28 12:33:15 +0300 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-06-01 19:11:26 +0200 |
| commit | 6f73eb9d90cfec684529aab48d517e3d6449ba8c (patch) | |
| tree | 4c25ff654a55ac837acc0621c8e473d4093f5d8d /docs | |
| parent | 9a3b7e5e2be751d28b8782ad23a63e1c75f27e24 (diff) | |
Fixed #33742 -- Added id to GeoJSON serializer.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/gis/serializers.txt | 9 | ||||
| -rw-r--r-- | docs/releases/4.2.txt | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/docs/ref/contrib/gis/serializers.txt b/docs/ref/contrib/gis/serializers.txt index 5ab3e56704..f3d465c385 100644 --- a/docs/ref/contrib/gis/serializers.txt +++ b/docs/ref/contrib/gis/serializers.txt @@ -25,6 +25,9 @@ serializer accepts the following additional option when it is called by 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). +* ``id_field``: A string containing the name of a field to use for the ``id`` + key of the GeoJSON feature. By default, the primary key of objects is used. + * ``srid``: The SRID to use for the ``geometry`` content. Defaults to 4326 (WGS 84). @@ -52,6 +55,7 @@ Would output:: 'features': [ { 'type': 'Feature', + 'id': 1, 'geometry': { 'type': 'Point', 'coordinates': [-87.650175, 41.850385] @@ -66,3 +70,8 @@ Would output:: 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. + +.. versionchanged:: 4.2 + + The ``id`` key for serialized features was added. Also, the ``id_field`` + option was added to the ``geojson`` serializer. diff --git a/docs/releases/4.2.txt b/docs/releases/4.2.txt index 0d95f68654..0c80c5b103 100644 --- a/docs/releases/4.2.txt +++ b/docs/releases/4.2.txt @@ -53,7 +53,9 @@ Minor features :mod:`django.contrib.gis` ~~~~~~~~~~~~~~~~~~~~~~~~~ -* ... +* The :doc:`GeoJSON serializer </ref/contrib/gis/serializers>` now outputs the + ``id`` key for serialized features, which defaults to the primary key of + objects. :mod:`django.contrib.messages` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
