From 8ba329e088554f4f351690dfa4c2c842b35db21c Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 21 Mar 2019 18:16:17 +0100 Subject: Gen cached label: fix innapropriate call to gen function --- ishtar_common/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index afb573da3..b0f08a3a1 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -414,7 +414,10 @@ def _cached_label_changed(sender, **kwargs): cached_labels = instance.CACHED_LABELS changed = [] for cached_label in cached_labels: - lbl = getattr(instance, '_generate_' + cached_label)() + gen_func = '_generate_' + cached_label + if not hasattr(instance, gen_func): + continue + lbl = getattr(instance, gen_func)() if lbl != getattr(instance, cached_label): changed.append((cached_label, lbl)) setattr(instance, cached_label, lbl) # update for cache @@ -439,6 +442,7 @@ def _cached_label_changed(sender, **kwargs): sender, ["cached_label_changed", instance.pk] ) cache.set(cache_key, None, settings.CACHE_TASK_TIMEOUT) + return getattr(instance, cached_labels[0], "") def regenerate_all_cached_labels(model): -- cgit v1.2.3