diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-11-18 10:41:05 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:23:19 +0100 |
commit | cda4a71a8cfff6abe7ba0345dabc0039bf7fe5ec (patch) | |
tree | d2a13e7ac4f3248a06a28ce1cf011a3d68393679 | |
parent | bff36572f3aaab10f9d1697cd398e733dcf0e5b7 (diff) | |
download | Ishtar-cda4a71a8cfff6abe7ba0345dabc0039bf7fe5ec.tar.bz2 Ishtar-cda4a71a8cfff6abe7ba0345dabc0039bf7fe5ec.zip |
Fix import when no object is created and no error is catched
-rw-r--r-- | ishtar_common/data_importer.py | 6 |
1 files changed, 4 insertions, 2 deletions
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="-"): |