diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-03-21 18:16:17 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:27 +0200 |
commit | 8ba329e088554f4f351690dfa4c2c842b35db21c (patch) | |
tree | c18e2741245120992075c33abe817914854735c5 /ishtar_common/utils.py | |
parent | 47038917365c6e4de78a8e89e26dce0d2395fe98 (diff) | |
download | Ishtar-8ba329e088554f4f351690dfa4c2c842b35db21c.tar.bz2 Ishtar-8ba329e088554f4f351690dfa4c2c842b35db21c.zip |
Gen cached label: fix innapropriate call to gen function
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): |