Alex Rivera | Logout

How to send multiple input field values with same name?

Asked 2009-01-25T21:55:12.493
13

I have m2m field, lets say it have name 'relations', so i want to allow user to send as many relations as he wants. I add new input to html with javascript with same name, like so

<input type='text' name='relations' value='a' />
<input type='text' name='relations' value='b' />

in cleaned_data i receive only value of second input ('b'). How to receive both?

Edit
Report

1 Answer

5

You don't need to grab all the raw values, you can just get the specific data by using element name like this:

relations = request.form.getlist('relations')

That will return a list of values in the relations input.

answered 2009-01-26T06:38:51.937

Your Answer