diff --git a/boards/models/post.py b/boards/models/post.py --- a/boards/models/post.py +++ b/boards/models/post.py @@ -286,13 +286,12 @@ class Post(models.Model, Viewable): thread.save(update_fields=['last_edit_time']) @cached_result - def get_url(self, thread=None): + def get_url(self): """ Gets full url to the post. """ - if not thread: - thread = self.get_thread() + thread = self.get_thread() opening_id = thread.get_opening_post_id() @@ -445,6 +444,11 @@ class Post(models.Model, Viewable): return self.text def get_absolute_id(self) -> str: + """ + If the post has many threads, shows its main thread OP id in the post + ID. + """ + if self.get_threads().count() > 1: return '{}/{}'.format(self.get_thread().get_opening_post_id(), self.id) else: diff --git a/boards/models/thread.py b/boards/models/thread.py --- a/boards/models/thread.py +++ b/boards/models/thread.py @@ -121,7 +121,7 @@ class Thread(models.Model): """ query = Post.objects.filter(threads__in=[self]) - query = query.order_by('pub_time').prefetch_related('images') + query = query.order_by('pub_time').prefetch_related('images', 'thread', 'threads') if view_fields_only: query = query.defer('poster_user_agent') return query.all() diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -13,7 +13,7 @@ {% endif %}