Tuesday, July 27, 2010

Best way to present N items in table row for list

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

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment