1
0
mirror of https://github.com/django/django.git synced 2025-01-18 14:24:39 +00:00

Fixed #36077 -- Corrected docs on pk value where Model.save() executes an UPDATE.

The empty string is no longer special-cased since
c2ba59fc1da5287d6286e2c2aca4083d5bafe056.
This commit is contained in:
Jacob Walls 2025-01-09 09:50:30 -05:00 committed by Sarah Boyce
parent 76a0b6aa3a
commit d66137b39b

View File

@ -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``.