5
More or less the same actually, just pass a list of values and it works.
MultiSubscriptionForm(initial={
'email': user.email,
'multiple_field': ['a', 'b', 'c'],
})
3
I got the same problem, Where I am the multiple checkboxes need to select dynamically (default selection of checkboxes) with initial value. I can able to manage the by passing the list.
mylist=['None','Fixed','Error']
error= forms.MultipleChoiceField(choices = formfields.ErrorType,widget = CheckboxSelectMultiple(),initial = mylist)
If I write the above code in my form class the values in mylist were selected by default when the form loads. your answer “Passing the values as list” solved my actual problem
Thanks for the clue
-Vikram
- [Django]-Docker build network error when trying to pip install
- [Django]-Django: Display contents of txt file on the website
- [Django]-Set image size limit and resize image if is needed
- [Django]-Can't debug django app in VS Code with docker database: 'could not translate host name "db" to address: Name or service not known'
- [Django]-How to make DRF serializer compatible with uppercase
Source:stackexchange.com