From fc86f178618a51e1198a1bafa882d9687f121441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 22 Jul 2015 16:14:00 +0200 Subject: [PATCH] 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. --- wcs/fields.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wcs/fields.py b/wcs/fields.py index d862cc5..8faf0b7 100644 --- a/wcs/fields.py +++ b/wcs/fields.py @@ -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])) -- 2.4.6