From dddb18cd875d7aeb3f959b7527701001ccdcb8b9 Mon Sep 17 00:00:00 2001 From: TKroenert Date: Sat, 5 Mar 2011 04:25:46 +0100 Subject: [PATCH] home ohne Pfand --- k4ever/main/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/k4ever/main/views.py b/k4ever/main/views.py index 865482b..8addc4d 100644 --- a/k4ever/main/views.py +++ b/k4ever/main/views.py @@ -7,9 +7,12 @@ from buyable.models import Purchase, Buyable @login_required def startpage(request): - allMost = Purchase.objects.values('buyable__name').annotate(num_buys=Count('buyable')).order_by('-num_buys') - usersMost = Purchase.objects.values('buyable__name').filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-num_buys') - usersLast = Purchase.objects.values('buyable__name').filter(order__user=request.user.id).order_by('-order__dateTime') + ''' Diese Funktion wird wahrscheinlich viel Last erzeugen, da + sie ueber mehrere Tabellen joined,filtered und wieder reduced. + ''' + allMost = Purchase.objects.filter(isDeposit=False).values('buyable__name').annotate(num_buys=Count('buyable')).order_by('-num_buys') + usersMost = Purchase.objects.filter(isDeposit=False).values('buyable__name').filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-num_buys') + usersLast = Purchase.objects.filter(isDeposit=False).values('buyable__name').filter(order__user=request.user.id).order_by('-order__dateTime') return render_to_response("main/startpage.html", {'allMost' : allMost,'usersMost': usersMost, 'usersLast' : usersLast}, RequestContext(request)) def register(request):