summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAnders Steinlein <anders@e5r.no>2014-03-05 21:19:40 +0100
committerTim Graham <timograham@gmail.com>2014-05-15 07:02:06 -0400
commit2914f66983a92fcae55673c517dd8d01e8c238c4 (patch)
tree05016c60eb19d8d80d628626081e737ebd0f8f5b /docs
parent93d5b0d5b6fac67fe7cbd3b86d3073550396958f (diff)
[1.7.x] Fixed #17642 -- Added min_num support to modelformsets, inlines, and the admin.
Thanks Stephen Burrows for work on the patch as well.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/checks.txt3
-rw-r--r--docs/ref/contrib/admin/index.txt20
-rw-r--r--docs/ref/contrib/contenttypes.txt6
-rw-r--r--docs/ref/forms/models.txt4
4 files changed, 29 insertions, 4 deletions
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 98a6e00e73..0b101c1816 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -204,7 +204,8 @@ inline on a :class:`~django.contrib.admin.ModelAdmin`.
* **admin.E202**: ``<model>`` has no ForeignKey to ``<parent model>``./``<model>`` has more than one ForeignKey to ``<parent model>``.
* **admin.E203**: The value of ``extra`` must be an integer.
* **admin.E204**: The value of ``max_num`` must be an integer.
-* **admin.E205**: The value of ``formset`` must inherit from ``BaseModelFormSet``.
+* **admin.E205**: The value of ``min_num`` must be an integer.
+* **admin.E206**: The value of ``formset`` must inherit from ``BaseModelFormSet``.
GenericInlineModelAdmin
~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index d6d4a75e6d..fc7e31896d 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1994,6 +1994,16 @@ The ``InlineModelAdmin`` class adds:
:meth:`InlineModelAdmin.get_max_num` also allows you to customize the
maximum number of extra forms.
+.. attribute:: InlineModelAdmin.min_num
+
+ .. versionadded:: 1.7
+
+ This controls the minimum number of forms to show in the inline.
+ See :func:`~django.forms.models.modelformset_factory` for more information.
+
+ :meth:`InlineModelAdmin.get_min_num` also allows you to customize the
+ minimum number of displayed forms.
+
.. attribute:: InlineModelAdmin.raw_id_fields
By default, Django's admin uses a select-box interface (<select>) for
@@ -2074,6 +2084,16 @@ The ``InlineModelAdmin`` class adds:
return max_num - 5
return max_num
+.. method:: InlineModelAdmin.get_min_num(request, obj=None, **kwargs)
+
+ .. versionadded:: 1.7
+
+ Returns the minimum number of inline forms to use. By default,
+ returns the :attr:`InlineModelAdmin.min_num` attribute.
+
+ Override this method to programmatically determine the minimum number of
+ inline forms. For example, this may be based on the model instance
+ (passed as the keyword argument ``obj``).
Working with a model with two or more foreign keys to the same parent model
---------------------------------------------------------------------------
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index bc8f538857..37db9f1b88 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -500,7 +500,7 @@ The :mod:`django.contrib.contenttypes.forms` module provides:
This class used to be defined in ``django.contrib.contenttypes.generic``.
-.. function:: generic_inlineformset_factory(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, validate_max=False, for_concrete_model=True)
+.. function:: generic_inlineformset_factory(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, validate_max=False, for_concrete_model=True, min_num=None, validate_min=False)
Returns a ``GenericInlineFormSet`` using
:func:`~django.forms.models.modelformset_factory`.
@@ -521,6 +521,10 @@ The :mod:`django.contrib.contenttypes.forms` module provides:
This function used to be defined in ``django.contrib.contenttypes.generic``.
+ .. versionchanged:: 1.7
+
+ ``min_num`` and ``validate_min`` were added.
+
.. module:: django.contrib.contenttypes.admin
diff --git a/docs/ref/forms/models.txt b/docs/ref/forms/models.txt
index 1d2b468553..688b800a40 100644
--- a/docs/ref/forms/models.txt
+++ b/docs/ref/forms/models.txt
@@ -45,7 +45,7 @@ Model Form Functions
The ``localized_fields``, ``labels``, ``help_texts``, and
``error_messages`` parameters were added.
-.. function:: modelformset_factory(model, form=ModelForm, formfield_callback=None, formset=BaseModelFormSet, extra=1, can_delete=False, can_order=False, max_num=None, fields=None, exclude=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None)
+.. function:: modelformset_factory(model, form=ModelForm, formfield_callback=None, formset=BaseModelFormSet, extra=1, can_delete=False, can_order=False, max_num=None, fields=None, exclude=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None, min_num=None, validate_min=False)
Returns a ``FormSet`` class for the given ``model`` class.
@@ -66,7 +66,7 @@ Model Form Functions
The ``widgets``, ``validate_max``, ``localized_fields``, ``labels``,
``help_texts``, and ``error_messages`` parameters were added.
-.. function:: inlineformset_factory(parent_model, model, form=ModelForm, formset=BaseInlineFormSet, fk_name=None, fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None)
+.. function:: inlineformset_factory(parent_model, model, form=ModelForm, formset=BaseInlineFormSet, fk_name=None, fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None, min_num=None, validate_min=False)
Returns an ``InlineFormSet`` using :func:`modelformset_factory` with
defaults of ``formset=``:class:`~django.forms.models.BaseInlineFormSet`,