[Fixed]-Setting initial values in Django Form

1👍

You need to set the initial attribute on the players field to be a list of the relevant MyUser ids. A quick way to do this is to use the initial keyword argument of ModelMultipleChoiceField:

players = forms.ModelMultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                         queryset=OPTIONS,
                                         initial=[u.pk for u in OPTIONS if u.player])

Leave a comment