summaryrefslogtreecommitdiff
path: root/tests/model_forms
diff options
context:
space:
mode:
Diffstat (limited to 'tests/model_forms')
-rw-r--r--tests/model_forms/test_modelchoicefield.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/model_forms/test_modelchoicefield.py b/tests/model_forms/test_modelchoicefield.py
index adb3754382..74ef14aa73 100644
--- a/tests/model_forms/test_modelchoicefield.py
+++ b/tests/model_forms/test_modelchoicefield.py
@@ -55,6 +55,10 @@ class ModelChoiceFieldTests(TestCase):
with self.assertRaisesMessage(ValidationError, msg):
f.clean(c4.id)
+ def test_clean_to_field_name(self):
+ f = forms.ModelChoiceField(Category.objects.all(), to_field_name='slug')
+ self.assertEqual(f.clean(self.c1.slug), self.c1)
+
def test_choices(self):
f = forms.ModelChoiceField(Category.objects.filter(pk=self.c1.id), required=False)
self.assertIsNone(f.clean(''))