-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Milestone
Description
The get_value method of ListField
seems to use if len(val) > 1:
where I believe it ought to be if len(val) >= 1:
or if len(val) > 0:
In a Django QueryDict
, for example, getlist
will yield a list of 1 item even if there is only one item. This seems to miss all the paths currently defined.
By way of example, here's a quick sketch of what I believe is demonstrable of the issue I think we're having:
>>> from rest_framework.fields import ListField
>>> from django.http import QueryDict
>>> qs = QueryDict('foo=1')
[u'1']
>>> qs2 = QueryDict('foo=1&foo=2')
[u'1', u'2']
>>> field = ListField()
>>> field.field_name = 'foo' # for the purposes of getting the prefix right
>>> field.get_value(qs2)
[u'1', u'2']
>>> field.get_value(qs)
[]
I'd expect the last, empty list []
to be [u'1']
This is against drf 3.2.0
and Django 1.8.x