Don't try to clear caches for nonexistant authors

This commit is contained in:
Mouse Reeve 2022-01-05 15:55:12 -08:00
parent b0fef8f0e3
commit 0f37e0ad42

View file

@ -39,12 +39,12 @@ class Author(BookDataModel):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
"""clear related template caches""" """clear related template caches"""
# clear template caches # clear template caches
cache_keys = [ if self.id:
make_template_fragment_key("titleby", [book]) cache_keys = [
for book in self.book_set.values_list("id", flat=True) make_template_fragment_key("titleby", [book])
] for book in self.book_set.values_list("id", flat=True)
cache.delete_many(cache_keys) ]
cache.delete_many(cache_keys)
return super().save(*args, **kwargs) return super().save(*args, **kwargs)
@property @property