Can I create a PHP style MultipleChoiceFilter field?
?field[]=var1&field[]=var2
That's the default.
The default is ?field=var1&field=var2
not ?field[]=var1&field[]=var2
.
Ah, I see... One way: You could use custom widget to affect the input rendering (to add the []
to the name
attribute)
You'll have to decide if it's what you want though:
>>> from django.http.request import QueryDict
>>> GET = QueryDict('field[]=var1&field[]=var2')
>>> GET
<QueryDict: {'field[]': ['var1', 'var2']}>
(You end up with the []
on the field name for the incoming data too.)
There is also the undocumented QueryArrayWidget
.
Ah, yes. Well done! There's already a widget. Great.
(I was sure we'd had this conversation before... 馃檪)
thks!!!!!
Most helpful comment
There is also the undocumented
QueryArrayWidget
.https://github.com/carltongibson/django-filter/blob/37f56385112b035e67b5a553ead7ed3a20ba426a/django_filters/widgets.py#L226-L255