**World Borders step.**
https://docs.djangoproject.com/en/4.0/ref/contrib/gis/tutorial/#worldborders
from this sentence:
`The world borders data is available in this zip file. Create a data
directory in the world application, download the world borders data, and
unzip.`
i download zip,
https://thematicmapping.org/downloads/TM_WORLD_BORDERS-0.3.zip
On the step **Defining a Geographic Model**:
I create class:
{{{
class WorldBorder(models.Model):
# GeoDjango-specific: a geometry field (MultiPolygonField)
mpoly = models.MultiPolygonField()
}}}
i think this is wrong in documentation.
Why i think so:
on the step **gdal-interface**
https://docs.djangoproject.com/en/4.0/ref/contrib/gis/tutorial/#gdal-
interface
we don't have any field/attribute in layer object, but we have attribute
"geom"
----
on the step **layermapping**
https://docs.djangoproject.com/en/4.0/ref/contrib/gis/tutorial/#layermapping
we have:
{{{
world_mapping = {
...
'mpoly' : 'MULTIPOLYGON',
}
}}}
i think this is wrong in documentation.
Why i think so:
at the same step, on the
{{{
layermapping.save(strict=True, verbose=verbose)
}}}
We resieve the error:
`An error occurred in the current transaction. You can't execute queries
until the end of the 'atomic' block. Failed to save {... 'geom':
'MULTIPOLYGON(....)'}`
And at the end:
on the step **Try ogrinspect**
https://docs.djangoproject.com/en/4.0/ref/contrib/gis/tutorial/#try-
ogrinspect
we reсeive a normal model with mapping:
{{{
class WorldBorder(models.Model):
...
geom = models.MultiPolygonField(srid=4326)
worldborders_mapping = {
...
'geom' : 'MULTIPOLYGON',
}
}}}
That's why i think, those parts of GeoDjango tutorial documentation is
wrong:
step **layermapping**,
step **Defining a Geographic Model**
and, the same error we have also on the page **LayerMapping data import
utility**.
https://docs.djangoproject.com/en/4.0/ref/contrib/gis/layermapping/
there we defined:
{{{
class TestGeo(models.Model):
...
poly = models.PolygonField(srid=4269) # we want our model in a
different SRID
mapping = {'name' : 'str', # The 'name' model field maps to the 'str'
layer field.
'poly' : 'POLYGON', # For geometry fields use OGC
name.
} # The mapping is a dictionary
}}}
if i use the same TM_WORLD_BORDERS-0.3.shp as a test_poly.shp
it is not works on the:
{{{
layermapping.save(verbose=True) # Save the layermap, imports the data.
}}}
with the same error.
From the 'Spatial queries' step, the author of the tutorial again uses the
'mpoly' field.
I think the field name "mpoly" was wrong to begin with, but it doesn't
matter to Django what I think, does it?
--
Ticket URL: <https://code.djangoproject.com/ticket/33694>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* keywords: geodjango, django.contrib.geo => geodjango, django.contrib.gis
--
Ticket URL: <https://code.djangoproject.com/ticket/33694#comment:1>
* status: new => closed
* resolution: => invalid
* easy: 1 => 0
Comment:
Thanks for this report, however
[https://docs.djangoproject.com/en/stable/ref/contrib/gis/tutorial/
GeoDjango Tutorial] works perfectly fine for me, a field name is not
important because we defined `world_mapping`. Closing per
TicketClosingReasons/UseSupportChannels
--
Ticket URL: <https://code.djangoproject.com/ticket/33694#comment:2>