mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[2.2.x] Fixed #30491 -- Clarified when save() on object with pk executes INSERT.
Backport of 67b6cb7723b2765cb776bd59d5603e3e63eefc2e from master
This commit is contained in:
parent
1172f078eb
commit
0f0d1cd772
@ -472,7 +472,8 @@ follows this algorithm:
|
||||
``True`` (i.e., a value other than ``None`` or the empty string), Django
|
||||
executes an ``UPDATE``.
|
||||
* If the object's primary key attribute is *not* set or if the ``UPDATE``
|
||||
didn't update anything, Django executes an ``INSERT``.
|
||||
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``.
|
||||
|
||||
The one gotcha here is that you should be careful not to specify a primary-key
|
||||
value explicitly when saving new objects, if you cannot guarantee the
|
||||
|
Loading…
x
Reference in New Issue
Block a user