db.models.Model.delete()

Model.delete(using=DEFAULT_DB_ALIAS, keep_parents=False) [source]

Issues an SQL DELETE for the object. This only deletes the object in the database; the Python instance will still exist and will still have data in its fields. This method returns the number of objects deleted and a dictionary with the number of deletions per object type.

For more details, including how to delete objects in bulk, see Deleting objects.

If you want customized deletion behavior, you can override the delete() method. See Overriding predefined model methods for more details.

Sometimes with multi-table inheritance you may want to delete only a child model’s data. Specifying keep_parents=True will keep the parent model’s data.

Changed in Django 1.9:

The keep_parents parameter was added.

Changed in Django 1.9:

The return value describing the number of objects deleted was added.

doc_Django
2016-10-09 18:35:53
Comments
Leave a Comment

Please login to continue.