How do you set the initial value for a ManyToMany field in django?
- by mlissner
I am using a ModelForm to create a form, and I have gotten the initial values set for every field in the form except for the one that is a ManyToMany field.
I understand that I need to give it a list, but I can't get it to work. My code right now is roughly:
contacts = userProfile.contact.all()
initial = {'contacts': contacts}
But that doesn't work. Am I missing something here?