# HG changeset patch # User neko259 # Date 2013-09-12 19:19:15 # Node ID e87e768dc2b5e19d7085ba9d1dfa93b0f62fd336 # Parent 27756a1b723158310e6d8705a82c3e98de38c09e Fixed image counting. Optimized image count. diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -240,11 +240,7 @@ class Post(models.Model): def get_images_count(self): images_count = 1 if self.image else 0 - - # TODO Use query here - for reply in self.replies: - if reply.image: - images_count += 1 + images_count += self.replies.filter(image_width__gt=0).count() return images_count