-
Notifications
You must be signed in to change notification settings - Fork 767
Open
Description
According to the docs (
django-filter/django_filters/widgets.py
Line 240 in 4a3eb8b
| class QueryArrayWidget(BaseCSVWidget, forms.TextInput): |
The problem here is that a QueryDict (the actual data type) is a subclass of MultiValueDict and the result always returns False and the data never get into the if statement.
I fixed it by replacing the code with:
if not type(data) == MultiValueDict:
data = data.copy()
ret = {}
for key, value in data.items():
if type(value) == list:
value = list[0]
# treat value as csv string: ?foo=1,2
if isinstance(value, str):
ret[key] = [x.strip() for x in value.rstrip(",").split(",") if x]
data = MultiValueDict(ret)
But I'm sure there must be a better fix.
Metadata
Metadata
Assignees
Labels
No labels