summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-07-17 09:47:14 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-07-17 09:50:43 +0200
commit75499b6367c5ece13e02c2fdb275c6d9f28d7edf (patch)
tree0bb35f699badc2286e1596f1c23e4d6710bc64df
parentafd9202add8932d5e27a5eaab0c3c13d4fa6dcd2 (diff)
downloadIshtar-75499b6367c5ece13e02c2fdb275c6d9f28d7edf.tar.bz2
Ishtar-75499b6367c5ece13e02c2fdb275c6d9f28d7edf.zip
External id: manage related queryset
-rw-r--r--archaeological_warehouse/models.py1
-rw-r--r--ishtar_common/models.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py
index 3dba70355..a1565a687 100644
--- a/archaeological_warehouse/models.py
+++ b/archaeological_warehouse/models.py
@@ -827,6 +827,7 @@ class Container(DocumentItem, LightHistorizedItem, QRCodeItem, GeoItem,
self.index = 1
def save(self, *args, **kwargs):
+ self.pre_save()
super(Container, self).save(*args, **kwargs)
updated = False
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 7d7b6c872..faf3ad3dd 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2542,7 +2542,11 @@ def get_external_id(key, item):
obj = getattr(obj, k)
except ObjectDoesNotExist:
obj = None
- if callable(obj):
+ if hasattr(obj, 'all') and hasattr(obj, 'count'): # query manager
+ if not obj.count():
+ break
+ obj = obj.all()[0]
+ elif callable(obj):
obj = obj()
if obj is None:
break