diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2007-02-27 03:48:49 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2007-02-27 03:48:49 +0000 |
| commit | a419079347676ab4fccd264a5e9c555a2603b9bb (patch) | |
| tree | 6e0978544650c373f04cba503deda514381063fc | |
| parent | 6dfd32d4e84d9db1506298dea1822093ed6e153f (diff) | |
Fixed #2264: the docs now mention that delete() cascades. Thanks, Ubernostrum
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4636 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | docs/db-api.txt | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt index 99bb30054b..3dc0efbabd 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -1621,6 +1621,15 @@ For example, this deletes all ``Entry`` objects with a ``pub_date`` year of Entry.objects.filter(pub_date__year=2005).delete() +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:: + + b = Blog.objects.get(pk=1) + # This will delete the Blog and all of its Entry objects. + b.delete() + 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 |
