0

use the [] symbol in the name of the form field you are submitting like:

input type=checkbox name=whatever[] value=1

input type=checkbox name=whatever[] value=2

input type=checkbox name=whatever[] value=3

input type=checkbox name=whatever[] value=4

In PHP when you post, this will come in as

$whatever = array("1", "2", "3", "4");

and you can access them like:

$whatever[0]

which will yield you "1"

But I have python and django template.

z=[]

z = request.POST['whatever[]']
s = ','.join(str(n) for n in z)

I want to recive this s =1,2,3,4 but instead of this I habe only the last digit

1 Answer 1

2

Removed the [] symbol in the name. And after z = request.POST.getlist('whatever')

But this is not the way. Read django forms documentation

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.