diff --git a/django/db/models/base.py b/django/db/models/base.py index a4d5a0d553..0f07d235a9 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -1493,7 +1493,7 @@ class Model(AltersData, metaclass=ModelBase): ): # no value, skip the lookup continue - if f in self._meta.pk_fields and not self._state.adding: + if f in model_class._meta.pk_fields and not self._state.adding: # no need to check for unique primary key when editing continue lookup_kwargs[str(field_name)] = lookup_value diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py index 6b005fcef0..cc333a9ac2 100644 --- a/tests/model_inheritance/tests.py +++ b/tests/model_inheritance/tests.py @@ -343,6 +343,11 @@ class ModelInheritanceTests(TestCase): self.assertEqual(type(MethodOverride.foo), DeferredAttribute) + def test_full_clean(self): + restaurant = Restaurant.objects.create() + with self.assertNumQueries(0), self.assertRaises(ValidationError): + restaurant.full_clean() + class ModelInheritanceDataTests(TestCase): @classmethod