> I have an array and I want to use Django templating to display each > item in a table, grouped by 3 per row. > For example, if i have > arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] > Then I'd want it to show up as > <table> > <tr><td>a</td><td>b</td><td>c</td></tr> > <tr><td>d</td><td>e</td><td>f</td></tr> > <tr><td>g</td><td>h</td><td>i</td></tr> > <tr><td>j</td><td></td><td></td></tr> > </table> > > In general, the array could be any length, and it's possible I'd want > to do 4 or 5 per row, not necessarily 3. > > What's the easiest way to do this? Thanks a bunch.
I've solved this a couple times before on this list, so you might find either of these two threads (and the python code for creating a corresponding columnize template filter) useful: http://groups.google.com/group/django-users/browse_frm/thread/b5f531e2aba49b4a/ http://groups.google.com/group/django-users/browse_frm/thread/a9ca56a9f601271a/ It also allows you to tweak the values returned for the "empty" cells when it squares it off (your content of your last two <td> nodes), so you can pad with the empty string, or you can use something like " " as your padding. Hope this helps, -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 -~----------~----~----~----~------~----~------~--~---