From cda4a71a8cfff6abe7ba0345dabc0039bf7fe5ec Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 18 Nov 2022 10:41:05 +0100 Subject: Fix import when no object is created and no error is catched --- ishtar_common/data_importer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ishtar_common/data_importer.py') diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 61c294b28..ff803f3f8 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -2079,6 +2079,7 @@ class Importer(object): created = False post_save_keys = [] get_by_unicity_key = False + obj = None try: try: dct = {} @@ -2122,7 +2123,6 @@ class Importer(object): new_dct.update(dct) dct = new_dct - obj = None if self.simulate: q = cls.objects.filter(**dct) if not q.count(): @@ -2216,6 +2216,7 @@ class Importer(object): if ( not self.simulate and self.import_instance + and obj and hasattr(obj, "imports") and created ): @@ -2318,7 +2319,8 @@ class Importer(object): message ) ) - self._add_to_post_save(obj.__class__, obj.pk, idx_line) + if obj: + self._add_to_post_save(obj.__class__, obj.pk, idx_line) return obj, created def _format_csv_line(self, values, empty="-"): -- cgit v1.2.3