Malcolm Tredinnick a écrit : So the solution is :
In views.py : user_skill = user.userskill_set.all().select_related() results = [{'domain': o.name.domain, 'item': o} for o in user_skill] (exactly as said by Malcolm) And in the template : > {% regroup results by domain as domain_list %} > {% for d in domain_list %} > <li>{{ d.grouper }} > <ul> > {% for item in d.list %} > <li>...</li> > {% endfor %} > </ul> > </li> > {% endfor %} The only change I made was : {% regroup results|dictsort:"domain.name" by domain as domain_list %} otherwise, regroup was not always correct. and a small notice, to access values of the list, it is by using item.item.<name_of_your_field> : ex : item.item.name > That looks, to my eye at least, a bit neater than the original solution, > too. You *might* (completely untested) be able to get away with making > your results list be: > > results = list(user_skill) > results.sort(key=lambda x: x.getattr('domain').name)) > > and then grouping by "domain.name", but I'm not 100% certain that will > work. I did not test this one - I keep it in mind anyway :) Thanks a lot for your help Malcom ! Nicolas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---