#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070180af70a407-25b93b90-7254-4ee9-92c5-ca1809e55a9b-000000%40eu-central-1.amazonses.com.

Reply via email to