1

I have the following HTML form I am submitting to Django using post:

input id="array" type="text" class="arrayinput" name="array[]" placeholder="Thing 1">
input id="array" type="text" class="arrayinput" name="array[]" placeholder="Thing 2">
input id="array" type="text" class="arrayinput" name="array[]" placeholder="Thing 3">

And in the model of this form I have:

array = ListCharField(max_length=255, base_field=CharField(max_length=255, blank=True, null=True))

However when I submit this array, it tells me that the form is missing the field array.

I assume this is because the field is called array[] but obviously I cannot name a python variable this. On the other hand, I cannot find any way to make a HTML array that has the functionality I need.

2
  • Why are they an array in the first place if they aren't part of the same input? Commented Mar 14, 2017 at 7:51
  • @Sayse we needed a way to join an unlimited number of text input boxes into the same input/variable (so theres an unlimted number of these arrayinputs that you can create on the site with a button) Commented Mar 14, 2017 at 7:55

1 Answer 1

5

If the field is called array, then just use that name in the HTML. There's no reason to add that pointless [].

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

1 Comment

And this is why I hate working with HTML. Thank you :)

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.