Mercurial > public > sg101
comparison gpp/bio/views.py @ 329:000c006fee97
Various small changes to reduce database hits.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 23 Feb 2011 03:40:18 +0000 |
parents | 1ba2c6bf6eb7 |
children | d83296cac940 |
comparison
equal
deleted
inserted
replaced
328:3f9b9fd54b01 | 329:000c006fee97 |
---|---|
50 try: | 50 try: |
51 the_page = paginator.page(page) | 51 the_page = paginator.page(page) |
52 except InvalidPage: | 52 except InvalidPage: |
53 raise Http404 | 53 raise Http404 |
54 | 54 |
55 # Attach user profiles to each post to avoid using get_user_profile() in | 55 # Attach user profiles to each user to avoid using get_user_profile() in |
56 # the template. | 56 # the template. |
57 users = set(user.id for user in the_page.object_list) | 57 users = set(user.id for user in the_page.object_list) |
58 | 58 |
59 profiles = UserProfile.objects.filter(user__id__in=users).select_related() | 59 profiles = UserProfile.objects.filter(user__id__in=users).select_related() |
60 user_profiles = dict((profile.user.id, profile) for profile in profiles) | 60 user_profiles = dict((profile.user.id, profile) for profile in profiles) |
64 | 64 |
65 return render_to_response('bio/members.html', { | 65 return render_to_response('bio/members.html', { |
66 'page': the_page, | 66 'page': the_page, |
67 'type': type, | 67 'type': type, |
68 'num_members': num_members, | 68 'num_members': num_members, |
69 }, | 69 }, |
70 context_instance = RequestContext(request)) | 70 context_instance = RequestContext(request)) |
71 | 71 |
72 ####################################################################### | 72 ####################################################################### |
73 | 73 |
74 @login_required | 74 @login_required |