From 9684e7c095585059033ac29339b058931a6547e3 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 7 Apr 2012 14:51:25 -0500 Subject: 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 --- todolists/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'todolists') diff --git a/todolists/utils.py b/todolists/utils.py index 894f3f1..24101e8 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') -- cgit v1.2.3-24-g4f1b