Django persist ModelMultipleChoiceField selections
Django persist ModelMultipleChoiceField selections I have a ModelMultipleChoiceField that allows a user to select one or more of a set of my "community" model (akin to a user joining a subreddit). When the user reopens the page to select communities, there are no checkboxes on the fields that the user has selected before. I would like to make it so that previously selected communities stay with check boxes, and therefore when the user hits submit their previous choices won't be forgotten if they don't reselect the previous choices. Here is my form: class CustomChoiceField(forms.ModelMultipleChoiceField): def label_from_instance(self, obj): return obj.name class CommunitySelectForm(forms.ModelForm): community_preferences = CustomChoiceField(queryset=Community.objects.all(), widget=forms.CheckboxSelectMultiple) class Meta: model= UserQAProfile fields = ['community_preferences'] And here is my template: <div class="col-...