32👍
✅
If you make the field a forms.MultipleChoiceField rather than a forms.ChoiceField it will work better.
6👍
May this helpful for you
num_choices = ( ("1", "ONE"), ("2", "TWO"), ("3", "Three"), ("4", "Four"))
num_list = forms.MultipleChoiceField(choices=num_choices, required=True, widget=forms.CheckboxSelectMultiple(), label='Select No', initial=("1", "2"))
If you want to pass the ORM object directly, then you can try the following
num_list = forms.ModelMultipleChoiceField(Numbers.objects.all(), required=True, widget=forms.CheckboxSelectMultiple(), label='Select No')
- [Django]-How do I remove Label text in Django generated form?
- [Django]-Passing STATIC_URL to file javascript with django
- [Django]-With DEBUG=False, how can I log django exceptions to a log file
Source:stackexchange.com