From 902e5c0fb2d3f0772efbfebc8ff135926a2bb47a Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Wed, 29 Jul 2026 18:06:19 -0400 Subject: Refs #37139 -- Doc'd _is_pk_set() handling of DatabaseDefault. --- docs/ref/models/instances.txt | 12 +++++++++--- docs/releases/6.1.txt | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 429be8ac0c..a0dbc0f6b5 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -996,6 +996,12 @@ Other attributes .. method:: Model._is_pk_set() -The ``_is_pk_set()`` method returns whether the model instance's ``pk`` is set. -It abstracts the model's primary key definition, ensuring consistent behavior -regardless of the specific ``pk`` configuration. + The ``_is_pk_set()`` method returns whether the model instance's ``pk`` is + set. It abstracts the model's primary key definition, ensuring consistent + behavior regardless of the specific ``pk`` configuration. A + ``DatabaseDefault`` on an unsaved instance is considered unset. + + .. versionchanged:: 6.1 + + In earlier versions, ``True`` was returned for ``DatabaseDefault`` + values. diff --git a/docs/releases/6.1.txt b/docs/releases/6.1.txt index 4316a00dba..72251bf38b 100644 --- a/docs/releases/6.1.txt +++ b/docs/releases/6.1.txt @@ -508,6 +508,9 @@ Models using :class:`.RawSQL`, might have to be adjusted to also make use of quoting. +* :meth:`~django.db.models.Model._is_pk_set` now returns ``False`` for + ``DatabaseDefault`` values on unsaved instances. + System checks ------------- -- cgit v1.3