mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #27377 -- Clarified that prepopulated_fields doesn't work with OneToOneField.
This commit is contained in:
parent
3e43d24ad3
commit
6af23a4521
6 changed files with 19 additions and 6 deletions
|
@ -1006,8 +1006,8 @@ class PrepopulatedFieldsCheckTests(CheckTestCase):
|
|||
|
||||
self.assertIsInvalid(
|
||||
ValidationTestModelAdmin, ValidationTestModel,
|
||||
("The value of 'prepopulated_fields' refers to 'users', which must not be "
|
||||
"a DateTimeField, a ForeignKey, or a ManyToManyField."),
|
||||
"The value of 'prepopulated_fields' refers to 'users', which must not be "
|
||||
"a DateTimeField, a ForeignKey, a OneToOneField, or a ManyToManyField.",
|
||||
'admin.E028')
|
||||
|
||||
def test_valid_case(self):
|
||||
|
@ -1016,6 +1016,17 @@ class PrepopulatedFieldsCheckTests(CheckTestCase):
|
|||
|
||||
self.assertIsValid(ValidationTestModelAdmin, ValidationTestModel)
|
||||
|
||||
def test_one_to_one_field(self):
|
||||
class ValidationTestModelAdmin(ModelAdmin):
|
||||
prepopulated_fields = {'best_friend': ('name',)}
|
||||
|
||||
self.assertIsInvalid(
|
||||
ValidationTestModelAdmin, ValidationTestModel,
|
||||
"The value of 'prepopulated_fields' refers to 'best_friend', which must not be "
|
||||
"a DateTimeField, a ForeignKey, a OneToOneField, or a ManyToManyField.",
|
||||
'admin.E028'
|
||||
)
|
||||
|
||||
|
||||
class ListDisplayTests(CheckTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue