##// END OF EJS Templates
Use prefetch_related for threads to improve thread loading speed
neko259 -
r658:7a5453fe default
parent child Browse files
Show More
@@ -430,8 +430,7 b' class Thread(models.Model):'
430 430 Gets sorted thread posts
431 431 """
432 432
433 # return self.replies.all().order_by('pub_time')
434 return self.replies.all().order_by('pub_time').select_related()
433 return self.replies.order_by('pub_time').all().prefetch_related('referenced_posts')
435 434
436 435 def add_tag(self, tag):
437 436 """
@@ -68,16 +68,14 b''
68 68 {{ post.text.rendered }}
69 69 {% endif %}
70 70 {% endautoescape %}
71 {% with refposts=post.referenced_posts.all %}
72 {% if refposts %}
73 <div class="refmap">
74 {% trans "Replies" %}:
75 {% for ref_post in refposts %}
76 <a href="{% post_object_url ref_post thread=thread %}">&gt;&gt;{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %}
77 {% endfor %}
78 </div>
79 {% endif %}
80 {% endwith %}
71 {% if post.referenced_posts.exists %}
72 <div class="refmap">
73 {% trans "Replies" %}:
74 {% for ref_post in post.referenced_posts.all %}
75 <a href="{% post_object_url ref_post thread=thread %}">&gt;&gt;{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %}
76 {% endfor %}
77 </div>
78 {% endif %}
81 79 </div>
82 80 {% endcache %}
83 81 {% if is_opening %}
General Comments 0
You need to be logged in to leave comments. Login now