diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-10-26 19:10:50 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:20 +0100 |
commit | 6e618dd23cde06ad0de944347beb037a8e36fbaa (patch) | |
tree | 3dfa0483278f237c4b3f0a3ad0f01365c9a80ccc /ishtar_common | |
parent | f2d0cfab5acd3f2deed313184e46210e15960647 (diff) | |
download | Ishtar-6e618dd23cde06ad0de944347beb037a8e36fbaa.tar.bz2 Ishtar-6e618dd23cde06ad0de944347beb037a8e36fbaa.zip |
Container: import_get_location for parent container
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/data_importer.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 2595134d0..1b3f8909d 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1685,6 +1685,8 @@ class Importer(object): try: for attribute in list(data.keys()): c_c_path = c_path[:] + if attribute not in data: # removed by previous get_field + continue if not attribute: data.pop(attribute) continue @@ -1821,17 +1823,20 @@ class Importer(object): [path, q.all()[0], dct, {}]) dct['defaults'] = defaults.copy() else: - if not self.MODEL_CREATION_LIMIT or \ - cls in self.MODEL_CREATION_LIMIT: - dct['defaults'] = defaults.copy() - obj, created = cls.objects.get_or_create(**dct) + if not dct and not defaults: + obj = None else: - try: - obj = cls.objects.get(**dct) + if not self.MODEL_CREATION_LIMIT or \ + cls in self.MODEL_CREATION_LIMIT: dct['defaults'] = defaults.copy() - except cls.DoesNotExist: - raise self._get_does_not_exist_in_db_error( - cls, dct) + obj, created = cls.objects.get_or_create(**dct) + else: + try: + obj = cls.objects.get(**dct) + dct['defaults'] = defaults.copy() + except cls.DoesNotExist: + raise self._get_does_not_exist_in_db_error( + cls, dct) if not created and not path and self.UNICITY_KEYS: updated_dct = {} |