diff options
| author | Tim Graham <timograham@gmail.com> | 2013-01-11 05:59:17 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-01-11 06:01:19 -0500 |
| commit | c94fcc4117987c4ebe29ad63da01035230c8afd5 (patch) | |
| tree | dbfd1aea65424f2f8cfb47cfcc30b581996f6cfe /django/forms | |
| parent | 72ef63bf86b12e752f186d562d9094cfde30af27 (diff) | |
[1.5.x] Fixed #10239 - Added docs for modelform_factory
Thanks ingenieroariel for the suggestion and slurms for the review.
Backport of 71d76ec011 from master
Diffstat (limited to 'django/forms')
| -rw-r--r-- | django/forms/models.py | 20 |
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. |
