Skip to content

Commit

Permalink
Fixed #34242 -- Doc'd that primary key is set to None when deleting o…
Browse files Browse the repository at this point in the history
…bjects.
  • Loading branch information
mron03 authored and felixxm committed Jan 20, 2023
1 parent cc8aa6b commit 5cd1385
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/ref/models/fields.txt
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ The primary key field is read-only. If you change the value of the primary
key on an existing object and then save it, a new object will be created
alongside the old one.

The primary key field is set to ``None`` when
:meth:`deleting <django.db.models.Model.delete>` an object.

``unique``
----------

Expand Down
5 changes: 3 additions & 2 deletions docs/ref/models/instances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,9 @@ Deleting objects

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.
its fields, except for the primary key set to ``None``. 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
:ref:`topics-db-queries-delete`.
Expand Down

0 comments on commit 5cd1385

Please sign in to comment.