So I have a model with a ManyToManyField called tournaments. I have a ModelForm with two tournament fields:
pay_tourns = forms.ModelMultipleChoiceField(
queryset=Tourn.objects.all().active().pay_tourns(),
widget=forms.CheckboxSelectMultiple())
rep_tourns = forms.ModelMultipleChoiceField(
queryset=Tourn.objects.all().active().rep_tourns(),
widget=forms.CheckboxSelectMultiple())
The methods after all() there are from a subclassed QuerySet. When I'm saving the form in my view I do thus:
post.tournaments = (post_form.cleaned_data.get('pay_tourns')
+ post_form.cleaned_data.get('rep_tourns'))
Anyway, this all works fine. What I can't figure out how to do is fill these form fields out when I'm loading an existing post. That is, when I pass instance=post to the form. Any ideas?