Bruno, Thanks for pointing me in the right direction, the only thing I needed to as was an order_by("category") to make sure all the bullet points were grouped by category.
Again, thank you so much for getting me past this. John On Nov 5, 1:02 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 4 nov, 23:54, John M <[EMAIL PROTECTED]> wrote: > > > i have a model for status reports:http://dpaste.com/88760/ > > > The report has 1-N bullet Points, each bullet Point has a category. > > > What I want to figure out, whats my best way to display this in a > > template, given that the category list is flexible. I mean, a report > > might have 1 or more categories. > > > I'd like to then group the bullet points for each category on the > > site. > > Not tested, but this should work AFAICT: > > # myview.py > def myview(resquest, report_id): > report = get_object_or_404(Report, pk=report_id) > context = dict( > report = report, > bullets = > report.bulletpoint_set.all().select_related('category') > } > return render_to_response('mytemplate.html', context) > > # mytemplate.html > {% regroup bullets by category as grouped_bullets %} > <ul> > {% for group in grouped_bullets %} > <li> > {{ group.grouper }} > <ul> > {% for bullet in group.list %} > <li>{{ bullet }}</li> > {% endfor %} > </li> > {% endfor %} > </ul> > > cfhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup > > HTH --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---