Refs #27003 -- Fixed SimpleArrayField crash on converted values.
This commit is contained in:
parent
74ed20b49a
commit
6573274161
1
AUTHORS
1
AUTHORS
|
@ -110,6 +110,7 @@ answer newbie questions, and generally made Django that much better:
|
|||
Bouke Haarsma <bouke@haarsma.eu>
|
||||
Božidar Benko <bbenko@gmail.com>
|
||||
Brad Melin <melinbrad@gmail.com>
|
||||
Brandon Chinn <http://brandonchinn178.github.io>
|
||||
Brant Harris
|
||||
Brendan Hayward <brendanhayward85@gmail.com>
|
||||
Brenton Simpson <http://theillustratedlife.com>
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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):
|
||||
|
||||
|
|
Loading…
Reference in New Issue