mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #29358 -- Added a system check to prohibit models with more than one primary_key field.
This commit is contained in:
parent
98019df855
commit
816b8d9518
3 changed files with 28 additions and 0 deletions
|
@ -717,6 +717,19 @@ class OtherModelTests(SimpleTestCase):
|
|||
)
|
||||
])
|
||||
|
||||
def test_single_primary_key(self):
|
||||
class Model(models.Model):
|
||||
foo = models.IntegerField(primary_key=True)
|
||||
bar = models.IntegerField(primary_key=True)
|
||||
|
||||
self.assertEqual(Model.check(), [
|
||||
Error(
|
||||
"Model can not contain more than one 'primary_key' field.",
|
||||
obj=Model,
|
||||
id='models.E026',
|
||||
)
|
||||
])
|
||||
|
||||
@override_settings(TEST_SWAPPED_MODEL_BAD_VALUE='not-a-model')
|
||||
def test_swappable_missing_app_name(self):
|
||||
class Model(models.Model):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue