diff --git a/boards/models/tag.py b/boards/models/tag.py --- a/boards/models/tag.py +++ b/boards/models/tag.py @@ -146,5 +146,5 @@ class Tag(models.Model, Viewable): def get_images(self): return Attachment.objects.filter( - post_attachments__thread__tags__in=[self]).filter( - mimetype__in=FILE_TYPES_IMAGE).order_by('-post_images__pub_time') \ No newline at end of file + attachment_posts__thread__tags__in=[self]).filter( + mimetype__in=FILE_TYPES_IMAGE).order_by('-attachment_posts__pub_time') \ No newline at end of file diff --git a/boards/models/thread.py b/boards/models/thread.py --- a/boards/models/thread.py +++ b/boards/models/thread.py @@ -142,7 +142,7 @@ class Thread(models.Model): return self.get_replies().filter( attachments__mimetype__in=FILE_TYPES_IMAGE)\ .annotate(images_count=Count( - 'attachments')).aggregate(Sum('images_count'))['images_count__sum'] + 'attachments')).aggregate(Sum('images_count'))['images_count__sum'] or 0 def can_bump(self) -> bool: """