summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-06-04 12:37:10 -0400
committerTim Graham <timograham@gmail.com>2014-06-04 12:37:10 -0400
commit2f7a7842baa50d74b9d4e93180375b7ff13b43e3 (patch)
tree4cb86b6e018b47b80d2529c83a7d82dda3c0f365 /docs
parent45e049937d2564d11035827ca9a9221b86215e45 (diff)
Fixed #22747 -- Add backwards compatibility tip for new behavior of formset.save(commit=False).
Thanks django at patjack.co.uk.
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/forms/formsets.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt
index 44d3154683..e4aa7b5984 100644
--- a/docs/topics/forms/formsets.txt
+++ b/docs/topics/forms/formsets.txt
@@ -509,6 +509,18 @@ model instances for deleted forms will be deleted when you call
>>> for obj in formset.deleted_objects:
... obj.delete()
+ If you want to maintain backwards compatibility with Django 1.6 and earlier,
+ you can do something like this::
+
+ >>> try:
+ >>> # For Django 1.7+
+ >>> for obj in formset.deleted_objects:
+ >>> obj.delete()
+ >>> except AssertionError:
+ >>> # Django 1.6 and earlier already deletes the objects, trying to
+ >>> # delete them a second time raises an AssertionError.
+ >>> pass
+
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.