summaryrefslogtreecommitdiff
path: root/docs/topics
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2010-11-09 16:46:42 +0000
committerCarl Meyer <carl@oddbird.net>2010-11-09 16:46:42 +0000
commit616b30227d901a7452810a9ffaa55eaf186dc9e1 (patch)
treea90a046c56bc8c25fc3ce5c0021c02b8ff77c0ba /docs/topics
parent3ba3294c6b5ad413731223a9e46064a8e132acd2 (diff)
Fixed #7539, #13067 -- Added on_delete argument to ForeignKey to control cascade behavior. Also refactored deletion for efficiency and code clarity. Many thanks to Johannes Dollinger and Michael Glassford for extensive work on the patch, and to Alex Gaynor, Russell Keith-Magee, and Jacob Kaplan-Moss for review.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14507 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics')
-rw-r--r--docs/topics/db/queries.txt13
1 files changed, 9 insertions, 4 deletions
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index 4a927cc35e..7a59f6f634 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -749,15 +749,20 @@ model (e.g., by iterating over a ``QuerySet`` and calling ``delete()``
on each object individually) rather than using the bulk ``delete()``
method of a ``QuerySet``.
-When Django deletes an object, it emulates the behavior of the SQL
-constraint ``ON DELETE CASCADE`` -- in other words, any objects which
-had foreign keys pointing at the object to be deleted will be deleted
-along with it. For example::
+When Django deletes an object, by default it emulates the behavior of the SQL
+constraint ``ON DELETE CASCADE`` -- in other words, any objects which had
+foreign keys pointing at the object to be deleted will be deleted along with
+it. For example::
b = Blog.objects.get(pk=1)
# This will delete the Blog and all of its Entry objects.
b.delete()
+.. versionadded:: 1.3
+ This cascade behavior is customizable via the
+ :attr:`~django.db.models.ForeignKey.on_delete` argument to the
+ :class:`~django.db.models.ForeignKey`.
+
Note that ``delete()`` is the only ``QuerySet`` method that is not exposed on a
``Manager`` itself. This is a safety mechanism to prevent you from accidentally
requesting ``Entry.objects.delete()``, and deleting *all* the entries. If you