#37135: LayerMapping utility seems unable to import PointFields with "unique"
keyword parameter
-------------------------------+--------------------------------------
     Reporter:  Agnès Haasser  |                     Type:  Bug
       Status:  new            |                Component:  GIS
      Version:  5.2            |                 Severity:  Normal
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------
 Hello,

 I'm trying to use LayerMapping in order to import Geographic Data in my
 database, in "update" mode. That is, I use "unique" parameter to check if
 LayerMapping should update existing entries or create new ones:


 {{{
 lm = LayerMapping(
             target_class,
             path_to_my_shp_file,
             my_mapping,
             unique=tuple_of_django_fields,
         )
 lm.save(strict=True, verbose=True)
 }}}


 When target_class has a geometry of type PointField, I get an error:



 {{{
 'Point' object is not iterable
 Traceback (most recent call last):
   File "file_on_disk/sia/gis_import/views.py", line 12, in launch_import
     databatch.import_geographic_data()
   File "file_on_disk/sia/gis_import/models.py", line 66, in
 import_geographic_data
     lm.save(strict=True, verbose=True)
   File "file_on_disk/venv/lib/python3.11/site-
 packages/django/contrib/gis/utils/layermapping.py", line 728, in save
     _save()
   File "file_on_disk/venv/lib/python3.11/site-
 packages/django/contrib/gis/utils/layermapping.py", line 653, in _save
     for g in new:
 TypeError: 'Point' object is not iterable
 }}}

 I'm using Django 5.2 so I have an older version of layermapping  but it
 seems the bug is still here in present source code (6.2 is not out yet as
 I write this ticket):

 
https://github.com/django/django/blob/ea9742c6d02edf64fc0969f21506f2048c976051/django/contrib/gis/utils/layermapping.py#L661-L663
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37135>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019e8337f498-d86e2adf-d265-4559-a7f8-10b4fcf84183-000000%40eu-central-1.amazonses.com.

Reply via email to