diff gpp/forums/views.py @ 189:db202792d9f5

Explicitly set session settings. Use the cache_db engine. Some minor tweaks to reduce some queries in forums.
author Brian Neal <bgneal@gmail.com>
date Thu, 01 Apr 2010 01:39:37 +0000
parents 500e5875a306
children 8c1832b9d815
line wrap: on
line diff
--- a/gpp/forums/views.py	Wed Mar 31 01:58:20 2010 +0000
+++ b/gpp/forums/views.py	Thu Apr 01 01:39:37 2010 +0000
@@ -19,6 +19,7 @@
 from django.template import RequestContext
 from django.views.decorators.http import require_POST
 from django.utils.text import wrap
+from django.db.models import F
 
 from core.paginator import DiggPaginator
 from core.functions import email_admins
@@ -152,13 +153,14 @@
     """
     Displays all the posts in a topic.
     """
-    topic = get_object_or_404(Topic.objects.select_related(), pk=id)
+    topic = get_object_or_404(Topic.objects.select_related(
+        'forum', 'forum__category', 'last_post'), pk=id)
 
     if not topic.forum.category.can_access(request.user):
         return HttpResponseForbidden()
 
-    topic.view_count += 1
-    topic.save()
+    topic.view_count = F('view_count') + 1
+    topic.save(force_update=True)
 
     posts = topic.posts.select_related()