From b325864686f1c1ffbe7062618e9cdfe0b5c45a35 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Thu, 9 Jan 2025 09:50:30 -0500 Subject: [PATCH] [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 c2ba59fc1da5287d6286e2c2aca4083d5bafe056. Backport of d66137b39b1503ca3d4d4fac687251adbc845068 from main. --- docs/ref/models/instances.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 9cf47a0fc5..4fd3e0052c 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -552,9 +552,8 @@ object's primary key attribute does **not** define a :attr:`~django.db.models.Field.default` or :attr:`~django.db.models.Field.db_default`, Django follows this algorithm: -* If the object's primary key attribute is set to a value that evaluates to - ``True`` (i.e., a value other than ``None`` or the empty string), Django - executes an ``UPDATE``. +* If the object's primary key attribute is set to anything except ``None``, + Django executes an ``UPDATE``. * If the object's primary key attribute is *not* set or if the ``UPDATE`` didn't update anything (e.g. if primary key is set to a value that doesn't exist in the database), Django executes an ``INSERT``.