From 737587eda4391494b1c44caa5e21ad7c2ff9ef50 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 26 Jun 2025 20:45:11 +0200 Subject: ⚡️ imports: performance optimisations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- archaeological_warehouse/models.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'archaeological_warehouse/models.py') diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index 9700e689a..9a253e735 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -1693,8 +1693,12 @@ class Container( return None, error_msg return current_localisation = Container.objects.create(**dct) + current_localisation_id = current_localisation.id + # do not use save is query friendly + self.__class__.objects.filter(pk=self.id).update( + parent_id=current_localisation_id) + # update the cached value of the parent - safer for post-treatments self.parent = current_localisation - self.save() if return_errors: return current_localisation, None return current_localisation @@ -1966,12 +1970,12 @@ class Container( for find in self.finds.all(): updated = find.update_current_full_location(full_location) if updated: - find.skip_history_when_saving = True + find.no_post_process() find.save() for find in self.finds_ref.all(): updated = find.update_ref_full_location(full_location) if updated: - find.skip_history_when_saving = True + find.no_post_process() find.save() def pre_save(self): -- cgit v1.2.3