mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #19617 -- Refactored Form metaclasses to support more inheritance scenarios.
Thanks apollo13, funkybob and mjtamlyn for the reviews.
This commit is contained in:
parent
54cd930baf
commit
ac5ec7b8bc
8 changed files with 105 additions and 42 deletions
|
@ -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'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue