summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-08-23 04:08:24 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-08-23 04:08:24 +0000
commita5cbb892f8206c8f4ae8fd1bcff93b8251e6264e (patch)
treefbfd1c7725d96882225e2ee29e60300852b80299 /django
parent1f770c62da69866835bb8fc9355128b6b493a97e (diff)
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
Diffstat (limited to 'django')
-rw-r--r--django/forms/models.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 527da5e3ba..254cca3db8 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -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.