Because SymptomeForm is a ModelForm, it will initialize its "parent" field as a ModelMultipleChoiceField, which I believe must be initialized with a queryset instead of a list.
On Sep 6, 4:30 pm, Thomas49 <evinrude_overcr...@hotmail.com> wrote: > Hello, > > I have two models, and the second contains a ManyToMany relationship: > > class TypeMedical(models.Model): > ... > > class Symptome(TypeMedical): > ... > parent = > models.ManyToManyField(TypeMedical,related_name='Parent',blank=True) > ... > > Then, I use a ModelForm in order to save data. > > class SymptomeForm(ModelForm): > class Meta: > model = Symptome > > When I create a form, sometimes I want to select a field in "parent". > How can I do that? I tried many things but nothing works. Ex: > sform = SymptomeForm(initial={'parent':["Acupuncture",]}) > > I hope someone can help! Thanks, > > Thomas. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.