From ba637af09598041b042c561ce1dc0e62e7561b1f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 5 Sep 2023 19:08:41 +0200 Subject: 🐛 import geo : fix import association when import_key is matched MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/data_importer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ishtar_common/data_importer.py') diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index ae4cb3675..8c46cadb6 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1237,6 +1237,7 @@ class Importer(object): }) GeoVectorData = apps.get_model("ishtar_common", "GeoVectorData") item = None + created = False if "import_key" in geodata: q = GeoVectorData.objects.filter( import_key=geodata["import_key"], @@ -1252,10 +1253,11 @@ class Importer(object): item.save() else: item = GeoVectorData.objects.create(**geodata) + created = True except Exception as e: self.errors.append((self.idx_line, None, str(e))) return - if self.import_instance: + if self.import_instance and created: item.imports.add(self.import_instance) if self.MAIN_GEO: obj.main_geodata = item -- cgit v1.2.3