diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-06-18 04:16:42 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-06-18 04:16:42 +0200 |
commit | 3e0ade895bc1100181d51440227e3b4201f58a74 (patch) | |
tree | d420631df8470942d2ce7ab63e909ebdd746a017 /ishtar_common/data_importer.py | |
parent | b76052c0c76d2d8e42d93ad7ddbadcaafe06e0fc (diff) | |
parent | 0db36c5e136bba3048bebbe1fda8f8c55afdec36 (diff) | |
download | Ishtar-3e0ade895bc1100181d51440227e3b4201f58a74.tar.bz2 Ishtar-3e0ade895bc1100181d51440227e3b4201f58a74.zip |
Merge branch 'stable'
Diffstat (limited to 'ishtar_common/data_importer.py')
-rw-r--r-- | ishtar_common/data_importer.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 1cdb167bc..2a20c245a 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -727,7 +727,8 @@ class Importer(object): for k in data['defaults']: setattr(t_obj, k, data['defaults'][k]) t_obj.save() - if self.import_instance and hasattr(t_obj, 'imports'): + if self.import_instance and hasattr(t_obj, 'imports') \ + and created: t_obj.imports.add(self.import_instance) for formater, val in self._post_processing: @@ -893,7 +894,7 @@ class Importer(object): v, created = model.objects.get_or_create( **v) if self.import_instance \ - and hasattr(v, 'imports'): + and hasattr(v, 'imports') and created: v.imports.add(self.import_instance) m2ms.append((attribute, v)) elif hasattr(field_object, 'rel') and field_object.rel and \ @@ -933,7 +934,8 @@ class Importer(object): dct = create_dict.copy() dct['defaults'] = defaults obj, created = cls.objects.get_or_create(**dct) - if self.import_instance and hasattr(obj, 'imports'): + if self.import_instance and hasattr(obj, 'imports') \ + and created: obj.imports.add(self.import_instance) except IntegrityError as e: raise IntegrityError(e.message) |