#26138 closed Cleanup/optimization (fixed)
GeoJSON Serializer doesn't include geometry_field if it's not in fields
| Reported by: | Bernd Schlapsi | Owned by: | Claude Paroz |
|---|---|---|---|
| Component: | GIS | Version: | 1.9 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The example in the documentation for GeoJSON Serializer don't work as described.
https://docs.djangoproject.com/es/1.9/ref/contrib/gis/serializers/
The tuple for the fields option is missing the 'point' field
from django.core.serializers import serialize
from my_app.models import City
serialize('geojson', City.objects.all(),
geometry_field='point',
fields=('name', 'point'))
If you use the example without the 'point' in the fields tuple the returning geometry property is null
{
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {'name': 'EPSG:4326'}
},
'features': [
{
'type': 'Feature',
'geometry': null,
'properties': {
'name': 'Chicago'
}
}
]
}
I think there should be a test-case in
https://github.com/django/django/blob/master/tests/gis_tests/geoapp/test_serializers.py
with a call to serialize used with both parameters (geometry_field and fields)
Change History (5)
comment:1 by , 10 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 10 years ago
| Has patch: | set |
|---|
comment:3 by , 10 years ago
| Summary: | Example for GeoJSON Serializer don't work as described → GeoJSON Serializer doesn't include geometry_field if it's not in fields |
|---|---|
| Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
PR