I have a class form that has the forms.MultipleChoiceField in it.
I am able to render it and show all the choices to select / highlight, but what I want is the choices that get displayed to be pre-highlighted. so it is up to the user to either deselect the options or leave them as they are when they submit the form.
Is there a way to do this ?
Thanks
You only need to set initial values to your field like this:
class YourForm(forms.Form):
choices = (
('choice1':'choice1'),
('choice2':'choice2'),
('choice3':'choice3')
)
#for example if you want to select choice1 and choice2
initial_values = ['choice1', 'choice2']
field = forms.MultipleChoiceField(initial=initial_values)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With