# HG changeset patch # User neko259 # Date 2015-02-04 13:01:52 # Node ID 110ab3b86519b754d0d1a0a100ef0eedcfefd0f6 # Parent 14f09a3c3de349c19d381e38ec0605a3f7014278 Cache tag post count diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -4,6 +4,7 @@ from django.db.models import Count from django.core.urlresolvers import reverse from boards.models.base import Viewable +from boards.utils import cached_result __author__ = 'neko259' @@ -70,5 +71,6 @@ class Tag(models.Model, Viewable): 'tag': self, }) + @cached_result def get_post_count(self): return self.get_threads().aggregate(num_posts=Count('post'))['num_posts']