diff options
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
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): |