changeset 190:0e4961833cdf

Added some select_related's to downloads.
author Brian Neal <bgneal@gmail.com>
date Thu, 01 Apr 2010 01:57:01 +0000 (2010-04-01)
parents db202792d9f5
children 046e6ef0ff45
files gpp/downloads/models.py gpp/downloads/views.py
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gpp/downloads/models.py	Thu Apr 01 01:39:37 2010 +0000
+++ b/gpp/downloads/models.py	Thu Apr 01 01:57:01 2010 +0000
@@ -43,7 +43,8 @@
 class PublicDownloadManager(models.Manager):
     """The manager for all public downloads."""
     def get_query_set(self):
-        return super(PublicDownloadManager, self).get_query_set().filter(is_public=True)
+        return super(PublicDownloadManager, self).get_query_set().filter(
+                is_public=True).select_related()
 
 
 class Download(models.Model):
--- a/gpp/downloads/views.py	Thu Apr 01 01:39:37 2010 +0000
+++ b/gpp/downloads/views.py	Thu Apr 01 01:57:01 2010 +0000
@@ -64,7 +64,8 @@
         sort = 'title'
     order_by = DOWNLOAD_FIELD_MAP[sort]
 
-    downloads = Download.public_objects.filter(category=cat.pk).order_by(order_by)
+    downloads = Download.public_objects.filter(category=cat.pk).order_by(
+            order_by)
     paginator = create_paginator(downloads)
     try:
         the_page = paginator.page(int(page))
@@ -202,7 +203,8 @@
 
     dls = Download.objects.filter(
             Q(title__icontains = query_text) |
-            Q(description__icontains = query_text)).order_by('title')
+            Q(description__icontains = query_text)).order_by(
+                    'title').select_related()
     paginator = create_paginator(dls)
     try:
         the_page = paginator.page(int(page))