summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index a1cc3cc1b..51cb16157 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -258,9 +258,9 @@ class Cached(object):
slug_field = 'txt_idx'
@classmethod
- def get_cache(cls, slug):
+ def get_cache(cls, slug, force=False):
cache_key, value = get_cache(cls, slug)
- if value:
+ if not force and value:
return value
try:
k = {cls.slug_field: slug}
@@ -270,8 +270,13 @@ class Cached(object):
except cls.DoesNotExist:
return None
+ def save(self, *args, **kwargs):
+ ret = super(Cached, self).save(*args, **kwargs)
+ self.get_cache(getattr(self, self.slug_field), force=True)
+ return ret
+
-class GeneralType(models.Model, Cached):
+class GeneralType(Cached, models.Model):
"""
Abstract class for "types"
"""