1

I am trying to get the values from multiple checkboxes via an Ajax request and use that data to filter a django object. The problem is that when I get the checkbox data in my js file with

'checkboxValues' : $('#filterForm').serialize()

the data gets sent to the my django view as: checks=value1&checks=value2

I have been trying to get this data in a usable form with:

checkbox_values = request.POST.getlist('checkboxValues')

but this just returns: [u'checks=value1&checks=value2']

Ultimately, I need it to return [value1, value2]

1 Answer 1

3

Good news...

> import urlparse
> urlparse.parse_qs("checks=value1&checks=value2")
{'checks': ['value1', 'value2']}

(See also: urlparse.parse_qsl, if it fits your needs better.)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.