Mercurial > public > sg101
diff shoutbox/views.py @ 791:0ca691cccf8d
Utilize select_related() for user & user profiles.
This commit also removes the caching of the avatar URL in the
avatar template tag. This is because we are now using select_related,
so we already have the profile & avatar when we get to the tag.
Thus we don't need to waste time querying the cache.
Removed an apparently unused member map template as well.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 23 May 2014 21:52:41 -0500 |
parents | ee87ea74d46b |
children | e932f2ecd4a7 |
line wrap: on
line diff
--- a/shoutbox/views.py Fri May 23 15:39:14 2014 -0500 +++ b/shoutbox/views.py Fri May 23 21:52:41 2014 -0500 @@ -54,7 +54,8 @@ def view_history(request): """This view allows one to view the shoutbox history.""" - paginator = DiggPaginator(Shout.objects.all().select_related(), + qs = Shout.objects.select_related('user', 'user__profile') + paginator = DiggPaginator(qs, SHOUTS_PER_PAGE, body=5, tail=3, margin=3, padding=2) page = get_page(request.GET) try: @@ -66,7 +67,7 @@ 'page': the_page, }, context_instance = RequestContext(request)) - + shout_id_re = re.compile(r'shout-(\d+)')