I’m pretty new to the world of Django / Python.
I have a the following query in a manager :
listOfHeroes = self.all().values('user__user__username','skill','level')
It return a table like this:
[{'user__user__username': u'Aragorn', 'skill': 'Fireball', 'level': 5}, {'user__user__username': u'Leonidas', 'skill': 'sword', 'level': 1},{'user__user__username': u'Aragorn', 'skill': 'sword', 'level': 4},....]
I want to group my data by heroes. I mean Aragorn has two skills Fireball and Sword :
User: Aragorn / Skills: { sword level 4 / fireball level 5}
Final datas I have where skills are grouped by User must be easily iterable.
If you have any ideas… I’ve tried to create a dictionary but I failed..
If you don’t want to change your database query, use this: