mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[2.1.x] Refs #28748 -- Reallowed lazy model field choices.
Regression in3aa9ab39cc. Backport ofc03e41712bfrom master
This commit is contained in:
		| @@ -4,6 +4,7 @@ from django.core.checks import Error, Warning as DjangoWarning | ||||
| from django.db import connection, models | ||||
| from django.test import SimpleTestCase, TestCase, skipIfDBFeature | ||||
| from django.test.utils import isolate_apps, override_settings | ||||
| from django.utils.functional import lazy | ||||
| from django.utils.timezone import now | ||||
| from django.utils.translation import gettext_lazy as _ | ||||
|  | ||||
| @@ -188,6 +189,12 @@ class CharFieldTests(TestCase): | ||||
|  | ||||
|         self.assertEqual(Model._meta.get_field('field').check(), []) | ||||
|  | ||||
|     def test_lazy_choices(self): | ||||
|         class Model(models.Model): | ||||
|             field = models.CharField(max_length=10, choices=lazy(lambda: [[1, '1'], [2, '2']], tuple)()) | ||||
|  | ||||
|         self.assertEqual(Model._meta.get_field('field').check(), []) | ||||
|  | ||||
|     def test_choices_named_group(self): | ||||
|         class Model(models.Model): | ||||
|             field = models.CharField( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user