mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Refs #373 -- Added Model._is_pk_set() abstraction to check if a Model's PK is set.
This commit is contained in:
@@ -31,7 +31,7 @@ class BaseGenericInlineFormSet(BaseModelFormSet):
|
||||
+ self.ct_fk_field.name
|
||||
)
|
||||
self.save_as_new = save_as_new
|
||||
if self.instance is None or self.instance.pk is None:
|
||||
if self.instance is None or not self.instance._is_pk_set():
|
||||
qs = self.model._default_manager.none()
|
||||
else:
|
||||
if queryset is None:
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user