From bff36572f3aaab10f9d1697cd398e733dcf0e5b7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 17 Nov 2022 15:36:57 +0100 Subject: Optimize context record relations post treatments --- archaeological_context_records/models.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'archaeological_context_records/models.py') diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index da6b3b86a..686b167b4 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -1714,6 +1714,8 @@ class ContextRecordTree(RelationsViews): @classmethod def _update(cls, item_id, already_updated=None): all_relations = set() + if not ContextRecord.objects.filter(pk=item_id).count(): + return # add self relation cls.objects.get_or_create( key=f"{item_id}_{item_id}", cr_id=item_id, cr_parent_id=item_id -- cgit v1.2.3