Look into formsets. It's what the admin inlines use.

On Tue, Sep 6, 2011 at 5:40 PM, Nan <ringe...@gmail.com> wrote:

>
> 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.
>
>


-- 
"The whole of Japan is pure invention. There is no such country, there are
no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

-- 
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.

Reply via email to