##// END OF EJS Templates
Optimized loading post images in post template
neko259 -
r694:597b8a7d 1.8-dev
parent child Browse files
Show More
@@ -87,8 +87,7 b' class Thread(models.Model):'
87 87 if reply_count > 0:
88 88 reply_count_to_show = min(settings.LAST_REPLIES_COUNT,
89 89 reply_count - 1)
90 replies = self.replies.order_by('pub_time').defer(
91 'poster_user_agent', 'text_markup_type')
90 replies = self.get_replies()
92 91 last_replies = replies[reply_count - reply_count_to_show:]
93 92
94 93 return last_replies
@@ -107,7 +106,7 b' class Thread(models.Model):'
107 106 Gets sorted thread posts
108 107 """
109 108
110 query = self.replies.order_by('pub_time')
109 query = self.replies.order_by('pub_time').prefetch_related('images')
111 110 if view_fields_only:
112 111 query = query.defer('poster_user_agent', 'text_markup_type')
113 112 return query.all()
@@ -161,4 +160,4 b' class Thread(models.Model):'
161 160 Gets opening post's pub time because thread does not have its own one.
162 161 """
163 162
164 return self.get_opening_post().pub_time No newline at end of file
163 return self.get_opening_post().pub_time
@@ -47,7 +47,7 b''
47 47 {% endif %}
48 48 </div>
49 49 {% if post.images.exists %}
50 {% with post.get_first_image as image %}
50 {% with post.images.all.0 as image %}
51 51 <div class="image">
52 52 <a
53 53 class="thumb"
General Comments 0
You need to be logged in to leave comments. Login now