summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-07-12 09:52:18 -0400
committerTim Graham <timograham@gmail.com>2013-07-23 16:21:23 -0400
commit65e03a424e82e157b4513cdebb500891f5c78363 (patch)
tree311eea583b0ba5e4510089036da388d48bee4a5b /docs
parent311c1d2848bde59bf03627e5c3d72b319285201b (diff)
Fixed #10284 -- ModelFormSet.save(commit=False) no longer deletes objects
Thanks laureline.guerin@ and Wedg.
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.7.txt5
-rw-r--r--docs/topics/forms/formsets.txt34
-rw-r--r--docs/topics/forms/modelforms.txt7
3 files changed, 38 insertions, 8 deletions
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index a7ab751dd4..bec24c94dc 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -94,6 +94,11 @@ Miscellaneous
have a custom :class:`~django.core.files.uploadhandler.FileUploadHandler`
that implements ``new_file()``, be sure it accepts this new parameter.
+* :class:`ModelFormSet<django.forms.models.BaseModelFormSet>`'s no longer
+ delete instances when ``save(commit=False)`` is called. See
+ :attr:`~django.forms.formsets.BaseFormSet.can_delete` for instructions on how
+ to manually delete objects from deleted forms.
+
Features deprecated in 1.7
==========================
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt
index 470d9f52e4..8be6e10ff6 100644
--- a/docs/topics/forms/formsets.txt
+++ b/docs/topics/forms/formsets.txt
@@ -3,7 +3,10 @@
Formsets
========
-.. class:: django.forms.formsets.BaseFormSet
+.. module:: django.forms.formsets
+ :synopsis: An abstraction for working with multiple forms on the same page.
+
+.. class:: BaseFormSet
A formset is a layer of abstraction to work with multiple forms on the same
page. It can be best compared to a data grid. Let's say you have the following
@@ -164,9 +167,7 @@ As we can see, ``formset.errors`` is a list whose entries correspond to the
forms in the formset. Validation was performed for each of the two forms, and
the expected error message appears for the second item.
-.. currentmodule:: django.forms.formsets.BaseFormSet
-
-.. method:: total_error_count(self)
+.. method:: BaseFormSet.total_error_count(self)
.. versionadded:: 1.6
@@ -353,6 +354,8 @@ formsets and deletion of forms from a formset.
``can_order``
~~~~~~~~~~~~~
+.. attribute:: BaseFormSet.can_order
+
Default: ``False``
Lets you create a formset with the ability to order::
@@ -411,6 +414,8 @@ happen when the user changes these values::
``can_delete``
~~~~~~~~~~~~~~
+.. attribute:: BaseFormSet.can_delete
+
Default: ``False``
Lets you create a formset with the ability to select forms for deletion::
@@ -463,10 +468,23 @@ delete fields you can access them with ``deleted_forms``::
If you are using a :class:`ModelFormSet<django.forms.models.BaseModelFormSet>`,
model instances for deleted forms will be deleted when you call
-``formset.save()``. On the other hand, if you are using a plain ``FormSet``,
-it's up to you to handle ``formset.deleted_forms``, perhaps in your formset's
-``save()`` method, as there's no general notion of what it means to delete a
-form.
+``formset.save()``.
+
+.. versionchanged:: 1.7
+
+ If you call ``formset.save(commit=False)``, objects will not be deleted
+ automatically. You'll need to call ``delete()`` on each of the
+ :attr:`formset.deleted_objects
+ <django.forms.models.BaseModelFormSet.deleted_objects>` to actually delete
+ them::
+
+ >>> instances = formset.save(commit=False)
+ >>> for obj in formset.deleted_objects:
+ ... obj.delete()
+
+On the other hand, if you are using a plain ``FormSet``, it's up to you to
+handle ``formset.deleted_forms``, perhaps in your formset's ``save()`` method,
+as there's no general notion of what it means to delete a form.
Adding additional fields to a formset
-------------------------------------
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt
index 0f3c5bb815..4ef7a6f074 100644
--- a/docs/topics/forms/modelforms.txt
+++ b/docs/topics/forms/modelforms.txt
@@ -825,6 +825,13 @@ to the database. If your formset contains a ``ManyToManyField``, you'll also
need to call ``formset.save_m2m()`` to ensure the many-to-many relationships
are saved properly.
+After calling ``save()``, your model formset will have three new attributes
+containing the formset's changes:
+
+.. attribute:: models.BaseModelFormSet.changed_objects
+.. attribute:: models.BaseModelFormSet.deleted_objects
+.. attribute:: models.BaseModelFormSet.new_objects
+
.. _model-formsets-max-num:
Limiting the number of editable objects