Refs #30302 -- Added more tests for forms.model_to_dict().

This commit is contained in:
belegnar 2019-04-03 08:59:08 +02:00 committed by Mariusz Felisiak
parent e6588aa4e7
commit 714cf468e1
No known key found for this signature in database
GPG Key ID: 2EF56372BA48CD1B
1 changed files with 3 additions and 0 deletions

View File

@ -1814,6 +1814,9 @@ class ModelOneToOneFieldTests(TestCase):
bw = BetterWriter.objects.create(name='Joe Better', score=10)
self.assertEqual(sorted(model_to_dict(bw)), ['id', 'name', 'score', 'writer_ptr'])
self.assertEqual(sorted(model_to_dict(bw, fields=['id', 'name'])), ['id', 'name'])
self.assertEqual(sorted(model_to_dict(bw, exclude=[])), ['id', 'name', 'score', 'writer_ptr'])
self.assertEqual(sorted(model_to_dict(bw, exclude=['id', 'name'])), ['score', 'writer_ptr'])
form = BetterWriterForm({'name': 'Some Name', 'score': 12})
self.assertTrue(form.is_valid())