summaryrefslogtreecommitdiff
path: root/tests/modeladmin/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modeladmin/tests.py')
-rw-r--r--tests/modeladmin/tests.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py
index ba75deff13..f8b4b5fae1 100644
--- a/tests/modeladmin/tests.py
+++ b/tests/modeladmin/tests.py
@@ -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):