##// 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 Gets sorted thread posts
430 Gets sorted thread posts
431 """
431 """
432
432
433 # return self.replies.all().order_by('pub_time')
433 return self.replies.order_by('pub_time').all().prefetch_related('referenced_posts')
434 return self.replies.all().order_by('pub_time').select_related()
435
434
436 def add_tag(self, tag):
435 def add_tag(self, tag):
437 """
436 """
@@ -68,16 +68,14 b''
68 {{ post.text.rendered }}
68 {{ post.text.rendered }}
69 {% endif %}
69 {% endif %}
70 {% endautoescape %}
70 {% endautoescape %}
71 {% with refposts=post.referenced_posts.all %}
71 {% if post.referenced_posts.exists %}
72 {% if refposts %}
72 <div class="refmap">
73 <div class="refmap">
73 {% trans "Replies" %}:
74 {% trans "Replies" %}:
74 {% for ref_post in post.referenced_posts.all %}
75 {% for ref_post in refposts %}
75 <a href="{% post_object_url ref_post thread=thread %}">&gt;&gt;{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %}
76 <a href="{% post_object_url ref_post thread=thread %}">&gt;&gt;{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %}
76 {% endfor %}
77 {% endfor %}
77 </div>
78 </div>
78 {% endif %}
79 {% endif %}
80 {% endwith %}
81 </div>
79 </div>
82 {% endcache %}
80 {% endcache %}
83 {% if is_opening %}
81 {% if is_opening %}
General Comments 0
You need to be logged in to leave comments. Login now