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:25:35 -0400
commit4ef10f245ada0c7d5ae8dc31eebffa63790d40fb (patch)
treedffd7ca06862fa20b5fa0b4528ac8beeecaee9fa /docs
parent860d31ac7a3bdd4b27db8b34b110b3d801ddaf8a (diff)
Fixed #17642 -- Added min_num support to modelformsets, inlines, and the admin.
Thanks Stephen Burrows for work on the patch as well. Forwardport of 2914f66983a92fcae55673c517dd8d01e8c238c4 from stable/1.7.x
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 67dc335d80..c8e97df660 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -205,7 +205,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 1a02d3fc3b..876bf290c3 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1966,6 +1966,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
@@ -2042,6 +2052,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 ccb9ccaa8e..eb93d2287f 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -495,7 +495,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`.
@@ -514,6 +514,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 f9bf847068..99ff9911f1 100644
--- a/docs/ref/forms/models.txt
+++ b/docs/ref/forms/models.txt
@@ -45,7 +45,7 @@ Model Form Functions
Previously, omitting the list of fields was allowed and resulted in
a form with all fields of the model.
-.. 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.
@@ -61,7 +61,7 @@ Model Form Functions
See :ref:`model-formsets` for example usage.
-.. 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`,