I have had similar issues while sorting with foreignkeys, try
specifying the sort like this :

{% regroup techskill.name.all|dictsort:"domain.id" by
domain as grouped %}

On Sep 11, 11:04 am, Nicolas Steinmetz <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Below my model with which I have an issue :
>
> """
> Technicat skills
> """
>
> class DomainTechSkill(models.Model):
>      name = models.CharField('Domaine de compétence technique',
> Maxlength=100, core=True)
>
> class Techskill(models.Model):
>      who = models.ForeignKey(User, verbose_name='Personne',)
>      name = models.CharField('Compétences techniques', maxlength=100,
> core=True)
>      domain = models.ForeignKey(DomainTechSkill, verbose_name='Domaine
> de compétences techniques',)
>
> class Usertechskill(models.Model):
>      who = models.ForeignKey(User, verbose_name='Personne',)
>      name = models.ManyToManyField(Techskill, verbose_name='Compétence
> technique', filter_interface=models.HORIZONTAL, blank=True)
>
> ... my view (part of):
> def cv_detail(request, firstname, lastname):
>      user = User.objects.get(first_name=firstname, last_name=lastname)
>      user_techskill = user.usertechskill_set.all()
>      return render_to_response('cv/cv_detail.html', {'user_techskill':
> user_techskill, })
>
> ... and my template :
>
>                  {# -- technical skills -- #}
>                  {% if user_techskill %}
>                  <p>Comp&eacute;tences techniques :</p>
>                  {% for techskill in user_techskill %}
>                  {% regroup techskill.name.all|dictsort:"domain" by
> domain as grouped %}
>                  <ul>
>                           {% for group in grouped %}
>                                  <li> {{ group.grouper }} :
>                                          {% for item in group.list %}
>                                                  {{ item.name }}{% if
> forloop.last %}.{% else %},{% endif %}
>                                          {% endfor %}
>                                  </li>
>                           {% endfor %}
>                  </ul>
>                  {% endfor %}
>                  {% endif %}
>
> Let's say I enter as technical skill / domain :
> - HTML / Web
> - CSS / Web
> - Apache / Servee
> - Portal / Information system
> - Bind / Server
> - CMS / Information System
>
> I may have as a result and what I expect :
>
> - Server : Apache, Bind
> - Information system : CMS, Portal
> - Web : HTML, CSS
>
> but sometimes I also have :
>
> - Server : Apache
> - Information system : CMS, Portal
> - Server : Bind
> - Web : HTML, CSS
>
> or any other combination of those values.
>
> Before rewriting user_techskill in my view so that all the sorting and
> ordreing is in the view and no longer or less in the template, did I
> miss something or did I make something wrong ?
>
> It's my last bug before I release my app so I would really appreciate
> any help solving this bug :-)
>
> Regards,
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to