Ticket #11183: 11183.2.diff
File 11183.2.diff, 1.8 KB (added by , 15 years ago) |
---|
-
django/forms/models.py
923 923 self.choice_cache = None 924 924 self.to_field_name = to_field_name 925 925 926 def __deepcopy__(self, memo): 927 result = super(ChoiceField, self).__deepcopy__(memo) 928 # Need to force a new ModelChoiceIterator to be created, bug #11183 929 result.queryset = result.queryset 930 return result 931 926 932 def _get_queryset(self): 927 933 return self._queryset 928 934 -
tests/regressiontests/model_forms_regress/tests.py
2 2 3 3 from django import db 4 4 from django import forms 5 from django.forms.models import modelform_factory 5 from django.forms.models import modelform_factory, ModelChoiceField 6 6 from django.conf import settings 7 7 from django.test import TestCase 8 8 … … 203 203 form = AuthorForm({'publication':u'', 'full_name':'John Doe'}, instance=author) 204 204 self.assert_(not form.is_valid()) 205 205 206 207 class ModelChoiceForm1(forms.Form): 208 person = ModelChoiceField(Person.objects.all()) 209 210 211 class TestTicket11183(TestCase): 212 def test_11183(self): 213 form1 = ModelChoiceForm1() 214 field1 = form1.fields['person'] 215 self.assert_(field1 is not ModelChoiceForm1.base_fields['person']) # sanity check 216 # To allow us to change the queryset of field1.widget.choices correctly, 217 # without affecting other forms, the following must hold: 218 self.assert_(field1.widget.choices.field is not ModelChoiceForm1.base_fields['person'])