Refs #30302 -- Added more tests for forms.model_to_dict().
This commit is contained in:
parent
e6588aa4e7
commit
714cf468e1
|
@ -1814,6 +1814,9 @@ class ModelOneToOneFieldTests(TestCase):
|
||||||
|
|
||||||
bw = BetterWriter.objects.create(name='Joe Better', score=10)
|
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)), ['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})
|
form = BetterWriterForm({'name': 'Some Name', 'score': 12})
|
||||||
self.assertTrue(form.is_valid())
|
self.assertTrue(form.is_valid())
|
||||||
|
|
Loading…
Reference in New Issue