mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Merge branch 'master' of github.com:tomchristie/django-rest-framework
This commit is contained in:
commit
fbd05aba57
|
@ -1391,7 +1391,7 @@ class ListField(Field):
|
|||
# lists in HTML forms.
|
||||
if html.is_html_input(dictionary):
|
||||
val = dictionary.getlist(self.field_name, [])
|
||||
if len(val) > 1:
|
||||
if len(val) > 0:
|
||||
# Support QueryDict lists in HTML input.
|
||||
return val
|
||||
return html.parse_html_list(dictionary, prefix=self.field_name)
|
||||
|
|
|
@ -317,6 +317,14 @@ class TestHTMLInput:
|
|||
assert serializer.is_valid()
|
||||
assert serializer.validated_data == {'scores': [1, 3]}
|
||||
|
||||
def test_querydict_list_input_only_one_input(self):
|
||||
class TestSerializer(serializers.Serializer):
|
||||
scores = serializers.ListField(child=serializers.IntegerField())
|
||||
|
||||
serializer = TestSerializer(data=QueryDict('scores=1&'))
|
||||
assert serializer.is_valid()
|
||||
assert serializer.validated_data == {'scores': [1]}
|
||||
|
||||
|
||||
class TestCreateOnlyDefault:
|
||||
def setup(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user