Ah!  Thanks Tom, that fixed it.

Tom

On Feb 22, 3:27 pm, Tom Evans <tevans...@googlemail.com> wrote:
> On Mon, Feb 22, 2010 at 3:11 PM, Tom <t.scr...@gmail.com> wrote:
> > Hi all,
>
> > I have a view that takes data from a form and saves it in the db.  One
> > of the fields is a M2M linking to another model.  The record itself
> > saves fine, but no entry in the M2M join table is created.  I am
> > passing the form initial data for the M2M in the form of a list of id
> > numbers specifying which items are to be selected.  Sure enough the
> > items are properly selected in the 'choose many' box, but the join
> > table is never made.
>
> > If anybody can provide a hint I would really appreciate it; I have
> > been going over and over this looking for an error and it is starting
> > to drive me crazy!
>
> > This is my code:
>
> > #views.py (to_form is the list of id numbers specifying the items to
> > be saved in the M2M field)
> > --------------
>
> > if request.method == 'POST':
> >                f = InteractionForm(request.POST)
> >                if f.is_valid():
>
> >                        interaction = f.save(commit=False)
> >                        interaction.owner = request.user
> >                        interaction.save()
> >                        return 
> > HttpResponseRedirect('http://127.0.0.1:8000/contact/%d'%
> > to_form[0])
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-sav...
>
> Pay particular attention to the notes about commit=False
>
> Cheers
>
> Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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