summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-10-26 19:37:47 -0400
committerTim Graham <timograham@gmail.com>2015-10-27 08:13:21 -0400
commit64a9115bcecf48bce2e7a84d165a6628e2ce607c (patch)
tree38ec95afd55b96b1496c3478d8e0bffc31f3f662
parente764f92cda2fca47294db4f5aaf2fed3d5e082b1 (diff)
[1.9.x] Fixed #25597 -- Fixed crash with SplitArrayField and IntegerField on invalid value.
Backport of 1f07da3e29c7c3d47968e1c4531dd9bf902575b7 from master
-rw-r--r--django/contrib/postgres/forms/array.py2
-rw-r--r--docs/releases/1.8.6.txt3
-rw-r--r--tests/postgres_tests/test_array.py5
3 files changed, 9 insertions, 1 deletions
diff --git a/django/contrib/postgres/forms/array.py b/django/contrib/postgres/forms/array.py
index 1e8b44f975..4eaae3e295 100644
--- a/django/contrib/postgres/forms/array.py
+++ b/django/contrib/postgres/forms/array.py
@@ -166,7 +166,7 @@ class SplitArrayField(forms.Field):
errors.append(None)
except ValidationError as error:
errors.append(ValidationError(
- string_concat(self.error_messages['item_invalid'], error.message),
+ string_concat(self.error_messages['item_invalid'], ' '.join(error.messages)),
code='item_invalid',
params={'nth': i},
))
diff --git a/docs/releases/1.8.6.txt b/docs/releases/1.8.6.txt
index d2f3bd8898..75bd79542b 100644
--- a/docs/releases/1.8.6.txt
+++ b/docs/releases/1.8.6.txt
@@ -38,3 +38,6 @@ Bugfixes
* Fixed a typo in the name of the `strictly_above` PostGIS lookup
(:ticket:`25592`).
+
+* Fixed crash with ``contrib.postgres.forms.SplitArrayField`` and
+ ``IntegerField`` on invalid value (:ticket:`25597`).
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index fbc15bb2ac..9f982178c7 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -509,6 +509,11 @@ class TestSplitFormField(PostgreSQLTestCase):
self.assertFalse(form.is_valid())
self.assertEqual(form.errors, {'array': ['Item 2 in the array did not validate: This field is required.']})
+ def test_invalid_integer(self):
+ msg = 'Item 1 in the array did not validate: Ensure this value is less than or equal to 100.'
+ with self.assertRaisesMessage(exceptions.ValidationError, msg):
+ SplitArrayField(forms.IntegerField(max_value=100), size=2).clean([0, 101])
+
def test_rendering(self):
class SplitForm(forms.Form):
array = SplitArrayField(forms.CharField(), size=3)