Opened 38 minutes ago
#37135 new Bug
LayerMapping utility seems unable to import PointFields with "unique" keyword parameter
| Reported by: | Agnès Haasser | Owned by: | |
|---|---|---|---|
| Component: | GIS | Version: | 5.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Agnès Haasser | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
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):
Note:
See TracTickets
for help on using tickets.