How to round Avg() to nearest integer? django

Viewed 4153

I have this in my views.py:

user_list = User.objects.select_related().annotate(rating=Avg('userrating__rating')).order_by('-rating')[:5]

And I want to round the Avg so I have nice round numbers for a rating.

However, if I use int(Avg('userrating__rating')))

it says:

int() argument must be a string or a number, not 'Avg'

if I use round(Avg('userrating__rating')) it says:

TypeError at / a float is required

same for math.ceil or math.floor

seems like a straight forward thing but I don't know how to do it. Thank you.

3 Answers
Related