knock down query count on topic page
This commit is contained in:
parent
31f376ff2d
commit
066d22cfbb
2 changed files with 4 additions and 2 deletions
|
@ -89,7 +89,7 @@
|
|||
</dl>
|
||||
</div>
|
||||
<div class="postright">
|
||||
<h3>{{ post.topic.name }}</h3>
|
||||
<h3>{{ topic.name }}</h3>
|
||||
<div class="postmsg">
|
||||
<div class="post_body_html">{{ post.body_html|safe }}</div>
|
||||
{% if post.updated %}
|
||||
|
|
|
@ -390,7 +390,9 @@ def show_topic(request, topic_id, full=True):
|
|||
|
||||
if request.user.is_authenticated():
|
||||
topic.update_read(request.user)
|
||||
posts = topic.posts.all().select_related()
|
||||
# without specifying, this query wouldn't select related properly, instead
|
||||
# it would query: forum_profile, userprofile, forum_topic, forum_attachment
|
||||
posts = topic.posts.select_related('user__userprofile').all()
|
||||
edit_start = timezone.now() - timedelta(minutes=1)
|
||||
edit_end = timezone.now()
|
||||
editable = posts.filter(created__range=(edit_start, edit_end)).filter(user_id=request.user.id)
|
||||
|
|
Reference in a new issue