2

I have a form like this:

<input name="field[1][title]" type="text">
<input name="field[1][placeholder]" type="text">
<input name="field[1][default]" type="text">

<input name="field[2][title]" type="text">
<input name="field[2][placeholder]" type="text">
<input name="field[2][default]" type="text">
<input name="field[2][max]" value="100" type="number">

<input name="field[3][title]" type="text">
<input name="field[3][placeholder]" type="text">
<input name="field[3][default]" type="text">

<input name="field[4][title]" type="text">
<input name="field[4][placeholder]" type="text">
<input name="field[4][default]" type="text">
<input name="field[4][max]" value="100" type="number">

...

How I can save each field as a model row in django?

Something like this:

for x in len(field):
    row = Row()
    row.title = field[x][title]
    row.placeholder = field[x][placeholder]
    row.default = field[x][default]
    row.save()

UPDATE

I have index key in form and I don't know how i can use in loop!

2

0

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.