1👍
✅
You can annotate the PlayerProfile
s with the umber of goals, and then order by that number and slice, so:
from django.db.models import Count
PlayerProfile.objects.annotate(
total_goals=Count('goal_maker')
).order_by('-total_goals')[:3]
Source:stackexchange.com