I've used that a lot and never had a problem.

I'd recommend stepping through the code.  When you call save, you go
into the save() function in django/forms/models.py, which immediatey
takes you into the save_Instance() method.  That code is quite
straight forward.  At the bottom it just looks at the value of commmit
and if it is False, it doesn't do the save.  Keep in mind that the
objects will be updated in memory in this case - just not saved out to
the db.

What makes you think that you are hitting the db when you do the
refererals_formset.save(commit=False)?

In any case, I think that commit=False is used a lot, so I'd walk
through your own code once more ...

Margie

On May 9, 7:17 pm, gorans <gor...@gmail.com> wrote:
> Hi all,
>
> I'm trying to use the .save(commit=False) method on a model formset in
> my view but for some strange reason, the django code executes the
> model's save method.
>
> My understanding of the docs is that when (commit=False) is passed -
> the formset will return a list of model instances but not commit them
> to the db.  However, when the formset's .save(commit=False) is called,
> I note that the model instances are saved. Documentation: [http://
> docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-
> formsets]
>
> I tried to trace through the django forms code to find out where this
> happens but could not.
>
> The code in my view is available here:http://dpaste.com/42538/
>
> I note that there is a line where the model gets explicitly saved so
> when I actually run that code the model gets saved twice - which I
> don't want to happen.
>
> Any help is much appreciated.
>
> Cheers
>
> Goran
--~--~---------~--~----~------------~-------~--~----~
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