diff options
| author | Nick Sandford <nick@sandford.id.au> | 2013-01-23 21:11:46 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2013-01-24 08:58:17 +0100 |
| commit | 93e79b45bc5288d1ca0eb5b6eade30d3c7110b24 (patch) | |
| tree | 38cf93875658c47a5644b3d9cafaded74966e54d /docs/topics/forms | |
| parent | 71c8539570dec000ad24d1a11fa443812b56f876 (diff) | |
Fixed #17416 -- Added widgets argument to inlineformset_factory and modelformset_factory
Diffstat (limited to 'docs/topics/forms')
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index c091e715bb..d9e00d86cf 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -650,6 +650,19 @@ exclude:: >>> AuthorFormSet = modelformset_factory(Author, exclude=('birth_date',)) +Specifying widgets to use in the form with ``widgets`` +------------------------------------------------------ + +.. versionadded:: 1.6 + +Using the ``widgets`` parameter, you can specify a dictionary of values to +customize the ``ModelForm``'s widget class for a particular field. This +works the same way as the ``widgets`` dictionary on the inner ``Meta`` +class of a ``ModelForm`` works:: + + >>> AuthorFormSet = modelformset_factory( + ... Author, widgets={'name': Textarea(attrs={'cols': 80, 'rows': 20}) + Providing initial values ------------------------ @@ -930,3 +943,13 @@ of a model. Here's how you can do that:: }) Notice how we pass ``instance`` in both the ``POST`` and ``GET`` cases. + +Specifying widgets to use in the inline form +-------------------------------------------- + +.. versionadded:: 1.6 + +``inlineformset_factory`` uses ``modelformset_factory`` and passes most +of its arguments to ``modelformset_factory``. This means you can use +the ``widgets`` parameter in much the same way as passing it to +``modelformset_factory``. See `Specifying widgets to use in the form with widgets`_ above. |
