diff options
| author | Csirmaz Bendegúz <csirmazbendeguz@gmail.com> | 2024-09-10 04:46:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-09 17:46:50 -0300 |
| commit | 5865ff5adcf64da03d306dc32b36e87ae6927c85 (patch) | |
| tree | 6fde8c074dc1ec5dab5db7c045f0ef40e649b719 /django/db/models/query_utils.py | |
| parent | cdbd31960e0cf41063b3efac97292ee0ccc262bb (diff) | |
Refs #373 -- Added Model._is_pk_set() abstraction to check if a Model's PK is set.
Diffstat (limited to 'django/db/models/query_utils.py')
| -rw-r--r-- | django/db/models/query_utils.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 096395e1b8..f0ae810f47 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -220,7 +220,7 @@ class DeferredAttribute: # might be able to reuse the already loaded value. Refs #18343. val = self._check_parent_chain(instance) if val is None: - if instance.pk is None and self.field.generated: + if not instance._is_pk_set() and self.field.generated: raise AttributeError( "Cannot read a generated field from an unsaved model." ) |
