Show More
@@ -237,13 +237,15 b' class Post(models.Model):' | |||
|
237 | 237 | poster_ip = models.GenericIPAddressField() |
|
238 | 238 | poster_user_agent = models.TextField() |
|
239 | 239 | |
|
240 |
thread_new = models.ForeignKey('Thread', null=True, default=None |
|
|
240 | thread_new = models.ForeignKey('Thread', null=True, default=None, | |
|
241 | db_index=True) | |
|
241 | 242 | last_edit_time = models.DateTimeField() |
|
242 | user = models.ForeignKey('User', null=True, default=None) | |
|
243 | user = models.ForeignKey('User', null=True, default=None, db_index=True) | |
|
243 | 244 | |
|
244 | 245 | referenced_posts = models.ManyToManyField('Post', symmetrical=False, |
|
245 | 246 | null=True, |
|
246 |
blank=True, related_name='rfp+' |
|
|
247 | blank=True, related_name='rfp+', | |
|
248 | db_index=True) | |
|
247 | 249 | |
|
248 | 250 | def __unicode__(self): |
|
249 | 251 | return '#' + str(self.id) + ' ' + self.title + ' (' + \ |
@@ -413,8 +415,10 b' class Thread(models.Model):' | |||
|
413 | 415 | reply_count_to_show = min(settings.LAST_REPLIES_COUNT, |
|
414 | 416 | reply_count - 1) |
|
415 | 417 | last_replies = self.replies.order_by( |
|
416 |
'pub_time'). |
|
|
417 | reply_count - reply_count_to_show:] | |
|
418 | 'pub_time').defer('image_hash', 'poster_user_agent', | |
|
419 | 'text_markup_type') \ | |
|
420 | .prefetch_related('referenced_posts')[ | |
|
421 | reply_count - reply_count_to_show:] | |
|
418 | 422 | |
|
419 | 423 | return last_replies |
|
420 | 424 | |
@@ -435,9 +439,8 b' class Thread(models.Model):' | |||
|
435 | 439 | query = self.replies.order_by('pub_time') |
|
436 | 440 | if view_fields_only: |
|
437 | 441 | query = query.defer( |
|
438 |
'image_hash', 'poster_user_agent', 'text_markup_type' |
|
|
439 | 'last_edit_time') | |
|
440 | return query.all() | |
|
442 | 'image_hash', 'poster_user_agent', 'text_markup_type') | |
|
443 | return query.all().prefetch_related('referenced_posts') | |
|
441 | 444 | |
|
442 | 445 | def add_tag(self, tag): |
|
443 | 446 | """ |
@@ -71,7 +71,7 b'' | |||
|
71 | 71 | {% if post.referenced_posts.exists %} |
|
72 | 72 | <div class="refmap"> |
|
73 | 73 | {% trans "Replies" %}: |
|
74 |
{% for ref_post in post. |
|
|
74 | {% for ref_post in post.referenced_posts %} | |
|
75 | 75 | <a href="{% post_object_url ref_post thread=thread %}">>>{{ ref_post.id }}</a>{% if not forloop.last %},{% endif %} |
|
76 | 76 | {% endfor %} |
|
77 | 77 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now