diff options
author | Dan McGee <dan@archlinux.org> | 2012-04-07 14:51:25 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-04-07 14:55:07 -0500 |
commit | 9684e7c095585059033ac29339b058931a6547e3 (patch) | |
tree | 43022c43d402c97e637c95ecd437d9faebe9f042 /todolists/utils.py | |
parent | ec7130f6ac194ce7ad53d06e3169030b16da6fed (diff) |
Prevent selection of many useless fields when getting todolists
This is a bit of a hack, but makes the resulting resultset returned from
the database a lot smaller and kills off all the columns we don't care
about and would never look at.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'todolists/utils.py')
-rw-r--r-- | todolists/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/todolists/utils.py b/todolists/utils.py index 894f3f1d..24101e86 100644 --- a/todolists/utils.py +++ b/todolists/utils.py @@ -2,9 +2,13 @@ from django.db.models import Count from main.models import Todolist + def get_annotated_todolists(): qs = Todolist.objects.all() - lists = qs.select_related('creator').annotate( + lists = qs.select_related('creator').defer( + 'creator__email', 'creator__password', 'creator__is_staff', + 'creator__is_active', 'creator__is_superuser', + 'creator__last_login', 'creator__date_joined').annotate( pkg_count=Count('todolistpkg')).order_by('-date_added') incomplete = qs.filter(todolistpkg__complete=False).annotate( Count('todolistpkg')).values_list('id', 'todolistpkg__count') |