comparison gpp/downloads/views.py @ 190:0e4961833cdf

Added some select_related's to downloads.
author Brian Neal <bgneal@gmail.com>
date Thu, 01 Apr 2010 01:57:01 +0000
parents 62eb9cbbcffc
children b4305e18d3af
comparison
equal deleted inserted replaced
189:db202792d9f5 190:0e4961833cdf
62 62
63 if sort not in DOWNLOAD_FIELD_MAP: 63 if sort not in DOWNLOAD_FIELD_MAP:
64 sort = 'title' 64 sort = 'title'
65 order_by = DOWNLOAD_FIELD_MAP[sort] 65 order_by = DOWNLOAD_FIELD_MAP[sort]
66 66
67 downloads = Download.public_objects.filter(category=cat.pk).order_by(order_by) 67 downloads = Download.public_objects.filter(category=cat.pk).order_by(
68 order_by)
68 paginator = create_paginator(downloads) 69 paginator = create_paginator(downloads)
69 try: 70 try:
70 the_page = paginator.page(int(page)) 71 the_page = paginator.page(int(page))
71 except InvalidPage: 72 except InvalidPage:
72 raise Http404 73 raise Http404
200 else: 201 else:
201 return HttpResponseRedirect(reverse('downloads-index')) 202 return HttpResponseRedirect(reverse('downloads-index'))
202 203
203 dls = Download.objects.filter( 204 dls = Download.objects.filter(
204 Q(title__icontains = query_text) | 205 Q(title__icontains = query_text) |
205 Q(description__icontains = query_text)).order_by('title') 206 Q(description__icontains = query_text)).order_by(
207 'title').select_related()
206 paginator = create_paginator(dls) 208 paginator = create_paginator(dls)
207 try: 209 try:
208 the_page = paginator.page(int(page)) 210 the_page = paginator.page(int(page))
209 except EmptyPage: 211 except EmptyPage:
210 dls = Download.objects.none() 212 dls = Download.objects.none()