mirror of
https://github.com/django/django.git
synced 2025-10-27 23:56:08 +00:00
[5.1.x] Fixed #36077 -- Corrected docs on pk value where Model.save() executes an UPDATE.
The empty string is no longer special-cased sincec2ba59fc1d. Backport ofd66137b39bfrom main.
This commit is contained in:
@@ -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.default` or
|
||||||
:attr:`~django.db.models.Field.db_default`, Django follows this algorithm:
|
: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
|
* If the object's primary key attribute is set to anything except ``None``,
|
||||||
``True`` (i.e., a value other than ``None`` or the empty string), Django
|
Django executes an ``UPDATE``.
|
||||||
executes an ``UPDATE``.
|
|
||||||
* If the object's primary key attribute is *not* set or if the ``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
|
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``.
|
exist in the database), Django executes an ``INSERT``.
|
||||||
|
|||||||
Reference in New Issue
Block a user