Skip to content

Commit b325864

Browse files
jacobtylerwallssarahboyce
authored andcommitted
[5.1.x] Fixed #36077 -- Corrected docs on pk value where Model.save() executes an UPDATE.
The empty string is no longer special-cased since c2ba59f. Backport of d66137b from main.
1 parent 8d81c47 commit b325864

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

docs/ref/models/instances.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,8 @@ object's primary key attribute does **not** define a
552552
:attr:`~django.db.models.Field.default` or
553553
:attr:`~django.db.models.Field.db_default`, Django follows this algorithm:
554554

555-
* If the object's primary key attribute is set to a value that evaluates to
556-
``True`` (i.e., a value other than ``None`` or the empty string), Django
557-
executes an ``UPDATE``.
555+
* If the object's primary key attribute is set to anything except ``None``,
556+
Django executes an ``UPDATE``.
558557
* If the object's primary key attribute is *not* set or if the ``UPDATE``
559558
didn't update anything (e.g. if primary key is set to a value that doesn't
560559
exist in the database), Django executes an ``INSERT``.

0 commit comments

Comments
 (0)