diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-03-19 10:59:27 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-06-17 13:21:27 +0200 |
commit | c2284c2c8f8c7b82ff19bbeaa19c90b0503d7482 (patch) | |
tree | f2852e88d47eb9efa031ff250d082fab002d8914 | |
parent | b5bce39917ae19ac183dcbf48bf991f57caa3697 (diff) | |
download | Ishtar-c2284c2c8f8c7b82ff19bbeaa19c90b0503d7482.tar.bz2 Ishtar-c2284c2c8f8c7b82ff19bbeaa19c90b0503d7482.zip |
Search vector and cached label update: update in cache
-rw-r--r-- | ishtar_common/models.py | 4 | ||||
-rw-r--r-- | ishtar_common/utils.py | 1 |
2 files changed, 2 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 06d706cdd..083da4cff 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -1572,6 +1572,7 @@ class FullSearch(models.Model): search_vectors.append(row[0]) new_search_vector = merge_tsvectors(search_vectors) changed = old_search != new_search_vector + self.search_vector = new_search_vector if save and changed: self.__class__.objects.filter(pk=self.pk).update( search_vector=new_search_vector) @@ -3217,9 +3218,6 @@ class Town(Imported, models.Model): return res def __str__(self): - if self.cached_label: - return self.cached_label - self.save() return self.cached_label @property diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 9bd81383f..afb573da3 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -417,6 +417,7 @@ def _cached_label_changed(sender, **kwargs): lbl = getattr(instance, '_generate_' + cached_label)() if lbl != getattr(instance, cached_label): changed.append((cached_label, lbl)) + setattr(instance, cached_label, lbl) # update for cache if changed: instance._search_updated = False if hasattr(instance, '_cascade_change') and instance._cascade_change: |