fields: ignore errors for shorter than expected rows in TableRowsField (#7905)

This is typical of the field gaining new columns after some forms were already
saved.
This commit is contained in:
Frédéric Péters 2015-07-22 16:14:00 +02:00
parent 596b6aaed4
commit 3d0fc529d7
1 changed files with 7 additions and 1 deletions

View File

@ -1484,7 +1484,13 @@ class TableRowsField(WidgetField):
for i, row_value in enumerate(value):
for j, column in enumerate(self.columns):
max_width = max(max_width, len(row_value[j]))
try:
max_width = max(max_width, len(row_value[j]))
except IndexError:
# ignore errors for shorter than expected rows, this is
# typical of the field gaining new columns after some forms
# were already saved.
pass
r.append(' '.join(['='*max_width]*(len(self.columns))))
r.append(' '.join([column.center(max_width) for column in self.columns]))