1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #14082 -- Use metaclass of provided ModelForm subclass in modelform_factory. Thanks jspiros and Stephen Burrows for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16334 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Carl Meyer
2011-06-07 16:15:54 +00:00
parent 64e19ffb4e
commit 684b0396cf
2 changed files with 23 additions and 2 deletions

View File

@@ -396,7 +396,12 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
'formfield_callback': formfield_callback
}
return ModelFormMetaclass(class_name, (form,), form_class_attrs)
form_metaclass = ModelFormMetaclass
if issubclass(form, BaseModelForm) and hasattr(form, '__metaclass__'):
form_metaclass = form.__metaclass__
return form_metaclass(class_name, (form,), form_class_attrs)
# ModelFormSets ##############################################################