summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2013-01-11 05:59:17 -0500
committerTim Graham <timograham@gmail.com>2013-01-11 06:00:19 -0500
commit71d76ec011b393990ba9f5fb63727dbe36c3c440 (patch)
tree836668d5322fff88c25caa1a09597369cf598a8e /django
parent4da5947a876a4ec2cba9de8b0ef1513832328c67 (diff)
Fixed #10239 - Added docs for modelform_factory
Thanks ingenieroariel for the suggestion and slurms for the review.
Diffstat (limited to 'django')
-rw-r--r--django/forms/models.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 27c246b668..1b6821cd5b 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -141,6 +141,11 @@ def fields_for_model(model, fields=None, exclude=None, widgets=None, formfield_c
``exclude`` is an optional list of field names. If provided, the named
fields will be excluded from the returned fields, even if they are listed
in the ``fields`` argument.
+
+ ``widgets`` is a dictionary of model field names mapped to a widget
+
+ ``formfield_callback`` is a callable that takes a model field and returns
+ a form field.
"""
field_list = []
ignored = []
@@ -371,6 +376,21 @@ class ModelForm(six.with_metaclass(ModelFormMetaclass, BaseModelForm)):
def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
formfield_callback=None, widgets=None):
+ """
+ Returns a ModelForm containing form fields for the given model.
+
+ ``fields`` is an optional list of field names. If provided, only the named
+ fields will be included in the returned fields.
+
+ ``exclude`` is an optional list of field names. If provided, the named
+ fields will be excluded from the returned fields, even if they are listed
+ in the ``fields`` argument.
+
+ ``widgets`` is a dictionary of model field names mapped to a widget.
+
+ ``formfield_callback`` is a callable that takes a model field and returns
+ a form field.
+ """
# Create the inner Meta class. FIXME: ideally, we should be able to
# construct a ModelForm without creating and passing in a temporary
# inner class.