diff --git a/AUTHORS b/AUTHORS index 75b947b1b8..4e475a4b25 100644 --- a/AUTHORS +++ b/AUTHORS @@ -110,6 +110,7 @@ answer newbie questions, and generally made Django that much better: Bouke Haarsma Božidar Benko Brad Melin + Brandon Chinn Brant Harris Brendan Hayward Brenton Simpson diff --git a/django/contrib/postgres/forms/array.py b/django/contrib/postgres/forms/array.py index bd3daaae0b..d22d9081e2 100644 --- a/django/contrib/postgres/forms/array.py +++ b/django/contrib/postgres/forms/array.py @@ -35,7 +35,9 @@ class SimpleArrayField(forms.CharField): return value def to_python(self, value): - if value: + if isinstance(value, list): + items = value + elif value: items = value.split(self.delimiter) else: items = [] diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py index db67ab714e..886a983180 100644 --- a/tests/postgres_tests/test_array.py +++ b/tests/postgres_tests/test_array.py @@ -677,6 +677,11 @@ class TestSimpleFormField(PostgreSQLTestCase): self.assertIsInstance(form_field, SimpleArrayField) self.assertEqual(form_field.max_length, 4) + def test_already_converted_value(self): + field = SimpleArrayField(forms.CharField()) + vals = ['a', 'b', 'c'] + self.assertEqual(field.clean(vals), vals) + class TestSplitFormField(PostgreSQLTestCase):