Hello, In my app, I have the following : - "Userskill" allows a given user to link 1 to n skills thanks to a Foreign Key to "Skill" model - In Skill model there is a foreign key to "Skilldomain".
I would like to display all the skills for a given user by skill domains. I have such models (simplified) : class Skilldomain(models.Model): name = models.CharField(_('Skill domain'), max_length=50) class Skill(models.Model): name = models.CharField(_('Skill'), max_length=50) domain = models.ForeignKey(Skilldomain, verbose_name=_('Skill domain')) class Userskill(models.Model): who = models.ForeignKey(User, verbose_name=_('Person')) name = models.ForeignKey(Skill, verbose_name=_('Skill')) I tried a lot of things but should miss a point somewhere. My last attempt is something like based on : user = User.objects.get(pk=1) user_skill = user.userskill_set.all().select_related() for k in user_skill: p = k.name print p.domain {# -- Skills -- #} {% if user_skill %} <div id="skill"> <strong>{% trans "Skills" %}</strong> <ul> {% for item in user_skill %} {% ifchanged %} <li>{{ item.name.domain }} {% endifchanged %} <ul> <li class="{{ item.level }}"><img src="/static/img/{{item.progress}}.png" alt="{{ item.get_progress_display }}" /><a href="{{ item.name.url }}" class="skill" rel="tag">{{ item.name }}</a></li> </ul> </li> {% endfor %} </ul> </div> {% endif %} This solution works except that I have a side effect with a <ul></ul> that I do not wish. I tried to do the same with "regroup" in template but could not manage to make it work in my case. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---