mirror of
https://github.com/django/django.git
synced 2025-03-12 10:22:37 +00:00
Fixed #36093 -- Adjusted unique checks to account for inherited primary keys.
Regression in bf7b17d16d3978b2e1cee4a0f7ce8840bd1a8dc4 refs #36075. Thanks Sage Abdullah for the report and tests.
This commit is contained in:
parent
e580926d74
commit
4bfec242b4
@ -1493,7 +1493,7 @@ class Model(AltersData, metaclass=ModelBase):
|
|||||||
):
|
):
|
||||||
# no value, skip the lookup
|
# no value, skip the lookup
|
||||||
continue
|
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
|
# no need to check for unique primary key when editing
|
||||||
continue
|
continue
|
||||||
lookup_kwargs[str(field_name)] = lookup_value
|
lookup_kwargs[str(field_name)] = lookup_value
|
||||||
|
@ -343,6 +343,11 @@ class ModelInheritanceTests(TestCase):
|
|||||||
|
|
||||||
self.assertEqual(type(MethodOverride.foo), DeferredAttribute)
|
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):
|
class ModelInheritanceDataTests(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user