Reputation: 1162
I am trying to have a form submitted with multiple values for one field that allows querying with an or statement. I have the MultipleChoiceField working that submits a get request as follows:
<QueryDict: {u'Selection': [u'option1', u'option2']}>
When I try and read an individual result from the request with
post = request.GET.get('Selection')
only 'option2' is returned and not the other selected item(s).
How can I turn the MultipleChoiceField into a query that selects 'option1' or 'option2'? Is there a better method of turning a form submission into an 'or' query? Thanks.
Upvotes: 0
Views: 178
Reputation: 37364
GET
is a QueryDict
object, which has special behavior when multiple values are submitted in the HTTP GET
for the same key. To get all of them, use the getlist
method. Alternatively, just use a form - the form field will collect the multiple values for you.
Upvotes: 1