X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/e92d6a9a4b4f3a29797f2f47e99787dce0ab525e..eb11e65717bdbddbc3ce08fa437739fd7bf5c279:/apps/catalogue/models.py diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 55a2b64b7..37e6c2e5e 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -131,8 +131,8 @@ class Book(models.Model): tagged = managers.ModelTaggedItemManager(Tag) tags = managers.TagDescriptor(Tag) - _tag_counter = JSONField(editable=False, default='') - _theme_counter = JSONField(editable=False, default='') + _tag_counter = JSONField(null=True, editable=False) + _theme_counter = JSONField(null=True, editable=False) class AlreadyExists(Exception): pass @@ -376,10 +376,9 @@ class Book(models.Model): @property def tag_counter(self): - if self._tag_counter == '': + if self._tag_counter is None: return self.refresh_tag_counter() return dict((int(k), v) for k, v in self.get__tag_counter_value().iteritems()) - #return self.get__tag_counter_value() def refresh_theme_counter(self): tags = {} @@ -392,10 +391,9 @@ class Book(models.Model): @property def theme_counter(self): - if self._theme_counter == '': + if self._theme_counter is None: return self.refresh_theme_counter() return dict((int(k), v) for k, v in self.get__theme_counter_value().iteritems()) - return self.get__theme_counter_value()