From ddc9671c40a86b1652d03f5a3e3e367ebd18d53d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 5 Jul 2023 16:48:00 +0200 Subject: 🐛 fix recursive save for cached label post_save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 673821c14..2becd20ce 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -635,10 +635,12 @@ def external_id_changed(sender, **kwargs): def _external_id_changed(sender, **kwargs): sender, instance = deserialize_args_for_tasks(sender, kwargs, EXTRA_KWARGS_TRIGGER) if not instance or not hasattr(instance, "external_id") \ - or not hasattr(instance, "auto_external_id"): + or not hasattr(instance, "auto_external_id") \ + or not hasattr(instance, "SLUG"): + return + if getattr(instance, "_external_id_checked", None): return updated = False - instance.no_post_process() if not instance.external_id or instance.auto_external_id: external_id = get_generated_id(instance.SLUG + "_external_id", instance) if external_id != instance.external_id: @@ -647,6 +649,7 @@ def _external_id_changed(sender, **kwargs): instance.external_id = external_id if hasattr(instance, "regenerate_all_ids"): updated |= instance.regenerate_all_ids(save=False) or False + instance._external_id_checked = True if updated: instance.save() -- cgit v1.2.3