summaryrefslogtreecommitdiff
path: root/django/contrib/postgres
diff options
context:
space:
mode:
authorCsirmaz Bendegúz <csirmazbendeguz@gmail.com>2024-09-10 04:46:50 +0800
committerGitHub <noreply@github.com>2024-09-09 17:46:50 -0300
commit5865ff5adcf64da03d306dc32b36e87ae6927c85 (patch)
tree6fde8c074dc1ec5dab5db7c045f0ef40e649b719 /django/contrib/postgres
parentcdbd31960e0cf41063b3efac97292ee0ccc262bb (diff)
Refs #373 -- Added Model._is_pk_set() abstraction to check if a Model's PK is set.
Diffstat (limited to 'django/contrib/postgres')
-rw-r--r--django/contrib/postgres/constraints.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
index 49124adc15..2eae101d5a 100644
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -198,7 +198,7 @@ class ExclusionConstraint(BaseConstraint):
lookups.append(lookup)
queryset = queryset.filter(*lookups)
model_class_pk = instance._get_pk_val(model._meta)
- if not instance._state.adding and model_class_pk is not None:
+ if not instance._state.adding and instance._is_pk_set(model._meta):
queryset = queryset.exclude(pk=model_class_pk)
if not self.condition:
if queryset.exists():