summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/data_importer.py23
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 = {}