[Django] #33694: GeoDjango tutorial documentation error.

9 views
Skip to first unread message

Django

unread,
May 10, 2022, 3:27:19 PM5/10/22
to django-...@googlegroups.com
#33694: GeoDjango tutorial documentation error.
-------------------------------------+-------------------------------------
Reporter: Maxim | Owner: nobody
Danilov |
Type: | Status: new
Cleanup/optimization |
Component: GIS | Version: 4.0
Severity: Normal | Keywords: geodjango,
Triage Stage: | django.contrib.geo
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
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?

--
Ticket URL: <https://code.djangoproject.com/ticket/33694>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 10, 2022, 3:40:54 PM5/10/22
to django-...@googlegroups.com
#33694: GeoDjango tutorial documentation error.
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: GIS | Version: 4.0
Severity: Normal | Resolution:
Keywords: geodjango, | Triage Stage:
django.contrib.gis | Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Maxim Danilov):

* keywords: geodjango, django.contrib.geo => geodjango, django.contrib.gis


--
Ticket URL: <https://code.djangoproject.com/ticket/33694#comment:1>

Django

unread,
May 11, 2022, 2:03:03 AM5/11/22
to django-...@googlegroups.com
#33694: GeoDjango tutorial documentation error.
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: GIS | Version: 4.0
Severity: Normal | Resolution: invalid

Keywords: geodjango, | Triage Stage:
django.contrib.gis | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* 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>

Reply all
Reply to author
Forward
0 new messages