On Jul 27, 12:51 pm, Wadim <wadim.ovchare...@gmail.com> wrote: > Hello. > I have a list that i want to present in a table. > Each row should have 5 items. > For now i create the function that returns me new grouped list, that i > use later in a template. > def groupListByRow(list): > cnt=0 > rows=[] > while cnt<len(list): > row=[] > for x in range(5): > if cnt<len(list): > row.append(list[cnt]) > else: > row.append(None) > cnt+=1 > rows.append(row) > return rows; > is there better way to do this? May be it is possible to do it inside > template? > Thanks
Are you sure you need a table and you can't just make a bunch of floating DIVs with some fixed width? If you need a table, I would personally prefer to do this in python code, like so: lst = range(42) rows = [] while lst: row, lst = lst[:5], lst[5:] rows.append(row + [None]*(5 - len(row))) -ak -- Django by Example Tutorials: http://lightbird.net/dbe/ Pysuite - Python Vim plugins: http://lightbird.net/pysuite/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.