diff options
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. |
