File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1391,7 +1391,7 @@ def get_value(self, dictionary):
1391
1391
# lists in HTML forms.
1392
1392
if html .is_html_input (dictionary ):
1393
1393
val = dictionary .getlist (self .field_name , [])
1394
- if len (val ) > 1 :
1394
+ if len (val ) > 0 :
1395
1395
# Support QueryDict lists in HTML input.
1396
1396
return val
1397
1397
return html .parse_html_list (dictionary , prefix = self .field_name )
Original file line number Diff line number Diff line change @@ -317,6 +317,14 @@ class TestSerializer(serializers.Serializer):
317
317
assert serializer .is_valid ()
318
318
assert serializer .validated_data == {'scores' : [1 , 3 ]}
319
319
320
+ def test_querydict_list_input_only_one_input (self ):
321
+ class TestSerializer (serializers .Serializer ):
322
+ scores = serializers .ListField (child = serializers .IntegerField ())
323
+
324
+ serializer = TestSerializer (data = QueryDict ('scores=1&' ))
325
+ assert serializer .is_valid ()
326
+ assert serializer .validated_data == {'scores' : [1 ]}
327
+
320
328
321
329
class TestCreateOnlyDefault :
322
330
def setup (self ):
You can’t perform that action at this time.
0 commit comments