mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #29247 -- Allowed blank model field choice to be defined in nested choices.
This commit is contained in:
@@ -140,6 +140,19 @@ class GetChoicesTests(SimpleTestCase):
|
||||
f = models.CharField(choices=choices)
|
||||
self.assertEqual(f.get_choices(include_blank=True), choices)
|
||||
|
||||
def test_blank_in_grouped_choices(self):
|
||||
choices = [
|
||||
('f', 'Foo'),
|
||||
('b', 'Bar'),
|
||||
('Group', (
|
||||
('', 'No Preference'),
|
||||
('fg', 'Foo'),
|
||||
('bg', 'Bar'),
|
||||
)),
|
||||
]
|
||||
f = models.CharField(choices=choices)
|
||||
self.assertEqual(f.get_choices(include_blank=True), choices)
|
||||
|
||||
def test_lazy_strings_not_evaluated(self):
|
||||
lazy_func = lazy(lambda x: 0 / 0, int) # raises ZeroDivisionError if evaluated.
|
||||
f = models.CharField(choices=[(lazy_func('group'), (('a', 'A'), ('b', 'B')))])
|
||||
|
||||
Reference in New Issue
Block a user