home ohne Pfand

This commit is contained in:
TKroenert 2011-03-05 04:25:46 +01:00
parent 47267b8213
commit dddb18cd87
1 changed files with 6 additions and 3 deletions

View File

@ -7,9 +7,12 @@ from buyable.models import Purchase, Buyable
@login_required @login_required
def startpage(request): def startpage(request):
allMost = Purchase.objects.values('buyable__name').annotate(num_buys=Count('buyable')).order_by('-num_buys') ''' Diese Funktion wird wahrscheinlich viel Last erzeugen, da
usersMost = Purchase.objects.values('buyable__name').filter(order__user=request.user.id).annotate(num_buys=Count('buyable')).order_by('-num_buys') sie ueber mehrere Tabellen joined,filtered und wieder reduced.
usersLast = Purchase.objects.values('buyable__name').filter(order__user=request.user.id).order_by('-order__dateTime') '''
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)) return render_to_response("main/startpage.html", {'allMost' : allMost,'usersMost': usersMost, 'usersLast' : usersLast}, RequestContext(request))
def register(request): def register(request):