I\'m trying to group records by the character of name
field of each record and limit the items in each group, here is what I have came up with:
desi
first ordering and then filtering is overkill and in vain. you should only order the data you need. Otherwise you are ordering all rows by name and then filtering and slicing what you need.
I would do:
User.objects.filter(name__startswith=desired_letter).order_by("name")[:10]
and .all()
was redundant.