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
commit4a35073f6e4239e52da931d314e691d624111926 (patch)
tree0bb35f699badc2286e1596f1c23e4d6710bc64df
parent91e2a7bc05b9decd3668bf739e4fbfa457ae01a6 (diff)
downloadIshtar-4a35073f6e4239e52da931d314e691d624111926.tar.bz2
Ishtar-4a35073f6e4239e52da931d314e691d624111926.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