performance: Use select_related when computing autocomplete lists.

(imported from commit fde08787998179451e6684a101c80aaafca917f6)
This commit is contained in:
Tim Abbott 2012-10-15 11:39:10 -04:00
parent a92be363d7
commit 7ebc720347
1 changed files with 2 additions and 2 deletions

View File

@ -158,10 +158,10 @@ def home(request):
people = [{'email' : profile.user.email, people = [{'email' : profile.user.email,
'full_name' : profile.full_name} 'full_name' : profile.full_name}
for profile in for profile in
UserProfile.objects.filter(realm=user_profile.realm) if UserProfile.objects.select_related().filter(realm=user_profile.realm) if
profile != user_profile] profile != user_profile]
subscriptions = Subscription.objects.filter(userprofile_id=user_profile, active=True) subscriptions = Subscription.objects.select_related().filter(userprofile_id=user_profile, active=True)
streams = [get_display_recipient(sub.recipient) for sub in subscriptions streams = [get_display_recipient(sub.recipient) for sub in subscriptions
if sub.recipient.type == Recipient.STREAM] if sub.recipient.type == Recipient.STREAM]