Lets say I have the following model
class Application(models.Model):
occupation = models.TextField()
and form
class ApplicationForm(forms.ModelForm):
def __init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self.fields['occupation'] = forms.MultipleChoiceField(choices=OCCUPATION_CHOICES, widget=CheckboxSelectMultiple)
class Meta:
model = Application
When I use it with a instance (for example via admin) the choices are not selected.
What am I doing wrong?
Edit: Clarification: When I select some choices, I hit submit it saves the data. They look like ['undergraduate', 'postdoc']
in the database. But they are not checked in the form anymore.