Initial data for ManyToMany field
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home