mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #15315 -- Added support for the 'widget' argument to modelform_factory. Thanks to SardarNL and Will Hardy for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16659 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -368,7 +368,7 @@ class ModelForm(BaseModelForm):
|
||||
__metaclass__ = ModelFormMetaclass
|
||||
|
||||
def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
|
||||
formfield_callback=None):
|
||||
formfield_callback=None, widgets=None):
|
||||
# Create the inner Meta class. FIXME: ideally, we should be able to
|
||||
# construct a ModelForm without creating and passing in a temporary
|
||||
# inner class.
|
||||
@@ -379,6 +379,8 @@ def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
|
||||
attrs['fields'] = fields
|
||||
if exclude is not None:
|
||||
attrs['exclude'] = exclude
|
||||
if widgets is not None:
|
||||
attrs['widgets'] = widgets
|
||||
|
||||
# If parent form class already has an inner Meta, the Meta we're
|
||||
# creating needs to inherit from the parent's inner meta.
|
||||
|
||||
Reference in New Issue
Block a user