python - django get sum of column based on where clause -
i have read documentation related django aggregation still have trouble figuring out how can sum of points per user.
here tried:
modelname.objects.filter(username=ruser.username).aggregate(sum('points'))
i following error:
request method: request url: http://localhost:8001/mypage/ django version: 1.4.8 exception type: nameerror exception value: global name 'sum' not defined
you need import sum first:
from django.db.models import sum
Comments
Post a Comment