﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33694	GeoDjango tutorial documentation error.	Maxim Danilov	nobody	"I try to follow GeoDjango tutorial.

**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?"	Cleanup/optimization	closed	GIS	4.0	Normal	invalid	geodjango, django.contrib.gis		Unreviewed	0	0	0	0	0	0
