mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +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.
|
# lists in HTML forms.
|
||||||
if html.is_html_input(dictionary):
|
if html.is_html_input(dictionary):
|
||||||
val = dictionary.getlist(self.field_name, [])
|
val = dictionary.getlist(self.field_name, [])
|
||||||
if len(val) > 1:
|
if len(val) > 0:
|
||||||
# Support QueryDict lists in HTML input.
|
# Support QueryDict lists in HTML input.
|
||||||
return val
|
return val
|
||||||
return html.parse_html_list(dictionary, prefix=self.field_name)
|
return html.parse_html_list(dictionary, prefix=self.field_name)
|
||||||
|
|
|
@ -317,6 +317,14 @@ class TestHTMLInput:
|
||||||
assert serializer.is_valid()
|
assert serializer.is_valid()
|
||||||
assert serializer.validated_data == {'scores': [1, 3]}
|
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:
|
class TestCreateOnlyDefault:
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user