Django {% regroup %} produces duplicate groups -


i've defined following models:

class topic(models.model): class meta:     ordering = [         'title']  objects = models.manager() highlighted = highlightedtopicmanager()  highlight = models.booleanfield(     default=false,     help_text='show topic on home page?',     db_index=true) highlight_order = models.positivesmallintegerfield(     default=0,     help_text='in order want added on home page?'\         ' leave blank alphabetic order.',     db_index=true) title = models.charfield(     max_length=2048,     db_index=true) slug = models.slugfield(     max_length=128,     db_index=true) excerpt = models.textfield(     null=true,     blank=true) description = models.textfield()  def _get_content(self):     if self.excerpt:         return self.excerpt     return self.description content = property(_get_content)  @models.permalink def get_absolute_url(self):     return ('academic_projects_topic_detail', (), {'slug': self.slug})  def __unicode__(self):     return self.title  class project(models.model): class meta:     ordering = [         'topic',         'modified',         'created']  objects = models.manager() highlighted = highlightedprojectmanager()  highlight = models.booleanfield(     help_text='highlight in projects\' main page?'\         ' modified 1 displayed.') redirect_to = models.urlfield(     blank=true,     null=true,     help_text='use old or extenal projects.') short_title = models.charfield(     max_length=1024,     db_index=true) slug = models.slugfield(     max_length=128,     db_index=true) title = models.charfield(     max_length=2048,     db_index=true) created = models.datetimefield(     auto_now_add=true) modified = models.datetimefield(     auto_now=true) excerpt = models.charfield(     max_length=1024,     null=true,     blank=true,     help_text='concise description show in listing page.') description = models.textfield(     null=true,     blank=true,     help_text='this content rendered right after title.') downloads = models.manytomanyfield(     download,     null=true,     blank=true,     help_text='downloadable files') footer = models.textfield(     null=true,     blank=true,     help_text='this content rendered @ bottom of page.') people = models.manytomanyfield(     person,     help_text='people involved in project.',     related_name='projects') organizations = models.manytomanyfield(     organization,     help_text='organizations involved other lab.',     blank=true,     null=true,     related_name='projects') publications = models.manytomanyfield(     publication,     blank=true,     null=true) topic = models.foreignkey(     topic,     verbose_name=_('main topic'),     help_text='this main topic.',     related_name='projects') sponsors = models.manytomanyfield(     sponsor,     blank=true,     null=true,     help_text='sponsored_projects') related_topics = models.manytomanyfield(     topic,     null=true,     blank=true,     help_text='optional related topics.',     related_name='secondary_projects')  def __unicode__(self):     return self.short_title  @models.permalink def get_absolute_url(self):     return ('academic_projects_project_detail', (), {'slug': self.slug}) 

and use following template produce page (http://seclab.cs.ucsb.edu/academic/projects/):

{% extends "academic/project_base.html" %}  {% block content_title %}projects{% endblock %} {% block title %}projects - {{block.super}}{% endblock %}  {% block content %}   {% regroup object_list|dictsort:"topic" topic topic_list %}    {% topic in topic_list %}   <h2 id="{{ topic.grouper.slug }}">{{ topic.grouper }} <a href="#{{ topic.grouper.slug }}">#</a></h2>   {% project in topic.list %}     <h3><a href="{{ project.get_absolute_url }}">{{ project }}</a></h3>     <p>{{ project.title }}</p>   {% endfor %}   {% endfor %} {% endblock %} 

the view behind generic one, , invoked as:

url(r'^$',     cache_page(listview.as_view(             queryset=project.objects.order_by('topic'),             template_name='academic/project_list.html')),     name='academic_projects_project_list'), 

so, projects sorted topic. unfortunately, code yields duplicate gorups and, sometimes, groups change @ each refresh (or, @ least, change when reboot server).

any idea of why happening? entire code, besides templates', resides here: https://bitbucket.org/phretor/django-academic/src/

the dictsort filter lists of dicts, don't need @ here. template should read

{% regroup object_list topic topic_list %} 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -