Ticket #2264: 2264.diff

File 2264.diff, 843 bytes (added by James Bennett, 18 years ago)

Patch documenting the cascading delete

  • docs/db-api.txt

     
    16211621
    16221622    Entry.objects.filter(pub_date__year=2005).delete()
    16231623
     1624When Django deletes an object, it emulates the behavior of the SQL
     1625constraint ``ON DELETE CASCADE`` -- in other words, any objects which
     1626had foreign keys pointing at the object to be deleted will be deleted
     1627along with it. For example::
     1628
     1629    b = Blog.objects.get(pk=1)
     1630    # This will delete the Blog and all of its Entry objects.
     1631    b.delete()
     1632
    16241633Note that ``delete()`` is the only ``QuerySet`` method that is not exposed on a
    16251634``Manager`` itself. This is a safety mechanism to prevent you from accidentally
    16261635requesting ``Entry.objects.delete()``, and deleting *all* the entries. If you
Back to Top