profile_list should select_related 'user'
Issue #7
resolved
I think it is very useful to have informations from User model at profile list page (like username). But profile_list doesn't select_related user field and django execute's query for every profile.
Profile_list view should have additional keyword argument - select_related. This should be a list of arguments passed to select_related in query.
Comments (3)
-
-
How to add attachment? ;x Here is a patch:
--- oldviews.py 2009-01-12 14:37:08.000000000 +0100 +++ views.py 2009-07-30 19:40:29.493396852 +0200 @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """ Views for creating, editing and viewing site-specific user profiles. @@ -285,7 +286,7 @@ context_instance=context) def profile_list(request, public_profile_field=None, - template_name='profiles/profile_list.html', **kwargs): + template_name='profiles/profile_list.html', select_related=['user'], **kwargs): """ A list of user profiles. @@ -333,5 +334,7 @@ queryset = profile_model._default_manager.all() if public_profile_field is not None: queryset = queryset.filter(**{ public_profile_field: True }) + if select_related is not None: + queryset = queryset.select_related(*select_related) kwargs['queryset'] = queryset return object_list(request, template_name=template_name, **kwargs)
-
- changed status to resolved
Due to changes in Django making it effectively obsolete, this application is no longer maintained.
- Log in to comment
Bump!