Fixed #19617 -- Refactored Form metaclasses to support more inheritance scenarios.

Thanks apollo13, funkybob and mjtamlyn for the reviews.
This commit is contained in:
Loic Bistuer 2013-07-21 02:25:27 +07:00
parent 54cd930baf
commit ac5ec7b8bc
8 changed files with 105 additions and 42 deletions

View file

@ -1802,3 +1802,16 @@ class M2mHelpTextTest(TestCase):
html = form.as_p()
self.assertInHTML('<ul id="id_status">', html)
self.assertInHTML(dreaded_help_text, html, count=0)
class ModelFormInheritanceTests(TestCase):
def test_form_subclass_inheritance(self):
class Form(forms.Form):
age = forms.IntegerField()
class ModelForm(forms.ModelForm, Form):
class Meta:
model = Writer
fields = '__all__'
self.assertEqual(list(ModelForm().fields.keys()), ['name', 'age'])