diff options
| author | Ramiro Morales <cramm0@gmail.com> | 2012-01-15 01:36:14 +0000 |
|---|---|---|
| committer | Ramiro Morales <cramm0@gmail.com> | 2012-01-15 01:36:14 +0000 |
| commit | e308cfc0e155f51f14c8eb4e678c15c5f632ae30 (patch) | |
| tree | 037ed46d6790adc32e1483c7240317e5ef31e38c /docs | |
| parent | 4e29b70b9dfb836a6ece537728f1ad9702786948 (diff) | |
Added support for specifying initial values to model formsets and inline formsets.
This make them consistent with the similar capability of regular
formsets. Thanks to simon29 form the report and to Claude Paroz for the
patch.
Fixes #14574.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17373 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.4.txt | 6 | ||||
| -rw-r--r-- | docs/topics/forms/formsets.txt | 2 | ||||
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 11 |
3 files changed, 19 insertions, 0 deletions
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index ea3e9a7fc9..9b3c219d31 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -556,6 +556,12 @@ Django 1.4 also includes several smaller improvements worth noting: * The MySQL database backend can now make use of the savepoint feature implemented by MySQL version 5.0.3 or newer with the InnoDB storage engine. +* It is now possible to pass initial values to the model forms that are part of + both model formsets and inline model formset as returned from factory + functions ``modelformset_factory`` and ``inlineformset_factory`` respectively + just like with regular formsets. However, initial values only apply to extra + forms i.e. those which are not bound to an existing model instance. + Backwards incompatible changes in 1.4 ===================================== diff --git a/docs/topics/forms/formsets.txt b/docs/topics/forms/formsets.txt index 37c3067f55..b524c24ad2 100644 --- a/docs/topics/forms/formsets.txt +++ b/docs/topics/forms/formsets.txt @@ -53,6 +53,8 @@ Formsets can also be indexed into, which returns the corresponding form. If you override ``__iter__``, you will need to also override ``__getitem__`` to have matching behavior. +.. _formsets-initial-data: + Using initial data with a formset --------------------------------- diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index 832a3acff0..cd1f43ae49 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -617,6 +617,17 @@ exclude:: >>> AuthorFormSet = modelformset_factory(Author, exclude=('birth_date',)) +Providing initial values +------------------------ + +.. versionadded:: 1.4 + +As with regular formsets, it is possible to :ref:`specify initial data +<formsets-initial-data>` for forms in the formset by specifying an ``initial`` +parameter when instantiating the model formset class returned by +``modelformset_factory``. However, with model formsets the initial values only +apply to extra forms, those which are not bound to an existing object instance. + .. _saving-objects-in-the-formset: Saving objects in the formset |
