From 75499b6367c5ece13e02c2fdb275c6d9f28d7edf Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 17 Jul 2019 09:47:14 +0200 Subject: External id: manage related queryset --- ishtar_common/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ishtar_common/models.py') 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 -- cgit v1.2.3