2π
β
It looks like you have multiple checkboxes on a page and each has the name groups
. This is perfectly OK.
When you submit a form like this, the params may look like this:
?groups=1&groups=3&groups=4
Your form definition, on the other hand, is defining groups as a CharField
. It will be populated with with a value retrieved from request.GET['groups']
which will only retrieve one of the above values.
I think you would be better off if you defined groups
as:
CHOICES = (
(0, '1'),
(1, '2'),
(2, '3'),
)
class MyForm(forms.Form):
groups = forms.MultipleChoiceField(
choices=CHOICES,
label="Groups",
required=False)
Source:stackexchange.com