> here it is: http://webapps.ubuntu.com/course_locator/ > > Click on Canada, and see what would ideally be a cross tab. > > The problem is, I'd like to have the event dates for training > events for the same course in the same town on the same row > (notice that several rows there differ only in the fact that > the training date is in August instead of July).
I'm not sure if you've gotten an answer to this, but I'm doing something of the sort in one of my Django apps. Sorry it's taken a while to get back. The basic gist is that I pass in the expected column headers as an iterable (list, tuple, whatever). I then print the headers for those months and then iterate over my data using the grouper...something like <table> <thead> <tr> <th>Description</th> {% for m in months %} <th>{{ m }}</th> {% endfor %} </tr> </thead> <tbody> {% regroup data by course_id as grouped %} {% for group in grouped %} <tr> <td>{{ group.grouper.course_description }}</td> {% for m in months %} <td> {% for course_date in group.list %} {% ifequal course_date|date:"Yd" m|date:"Yd" %} {{ m }} {% else %} {% endifequal %} {% endfor %} </td> {% endfor %} </tr> {% endfor %} </tbody> </table> > I know how to do this in SQL just fine, but as I've found, the > SQL way is not always the ideal way in Django. The above isn't terribly efficient with a triple-nested-loop in there. However, if your number of months and rows stays fairly small number, it should at least get you close without a horrible performance hit. If you force your months to a list/tuple before passing it in from the view, it won't hit the DB for each line. I don't know if you just pass them in as a recordset, if it hits the DB for each line. Just another idea to add to your mix, -tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---