Ticket #11872: inline_formsets_none_instance.diff
File inline_formsets_none_instance.diff, 1.4 KB (added by , 15 years ago) |
---|
-
django/forms/models.py
709 709 save_as_new=False, prefix=None): 710 710 from django.db.models.fields.related import RelatedObject 711 711 if instance is None: 712 self.instance = self. model()712 self.instance = self.fk.rel.to() 713 713 else: 714 714 self.instance = instance 715 715 self.save_as_new = save_as_new -
tests/regressiontests/model_formsets_regress/tests.py
140 140 self.assertEqual(manager[1]['name'], 'Terry Gilliam') 141 141 else: 142 142 self.fail('Errors found on formset:%s' % form_set.errors) 143 144 def test_formset_with_none_instance(self): 145 "A formset with instance=None can be created. Regression for #11872" 146 Form = modelform_factory(User) 147 FormSet = inlineformset_factory(User, UserSite) 148 149 # Instantiate the Form and FormSet to prove 150 # you can create a formset with an instance of None 151 form = Form(instance=None) 152 form_set = FormSet(instance=None) 153 154 155 156 No newline at end of file