mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[1.11.x] Fixed #27975 -- Fixed crash if ModelChoiceField's queryset=None.
Regression in 9153d8fbd6385db9f48793662de789fc3d686841.
Backport of 216bb2e8fb from master
			
			
This commit is contained in:
		| @@ -1646,6 +1646,17 @@ class ModelChoiceFieldTests(TestCase): | ||||
|         form2 = ModelChoiceForm() | ||||
|         self.assertIsNone(form2.fields['category'].queryset._result_cache) | ||||
|  | ||||
|     def test_modelchoicefield_queryset_none(self): | ||||
|         class ModelChoiceForm(forms.Form): | ||||
|             category = forms.ModelChoiceField(queryset=None) | ||||
|  | ||||
|             def __init__(self, *args, **kwargs): | ||||
|                 super(ModelChoiceForm, self).__init__(*args, **kwargs) | ||||
|                 self.fields['category'].queryset = Category.objects.filter(slug__contains='test') | ||||
|  | ||||
|         form = ModelChoiceForm() | ||||
|         self.assertCountEqual(form.fields['category'].queryset, [self.c2, self.c3]) | ||||
|  | ||||
|     def test_modelchoicefield_22745(self): | ||||
|         """ | ||||
|         #22745 -- Make sure that ModelChoiceField with RadioSelect widget | ||||
|   | ||||
		Reference in New Issue
	
	Block a user