summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/internals/deprecation.txt2
-rw-r--r--docs/ref/contrib/admin/index.txt25
-rw-r--r--docs/releases/1.7.txt19
3 files changed, 38 insertions, 8 deletions
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 9e473dfa46..c91ea2d218 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -453,6 +453,8 @@ these changes.
* ``django.db.backends.util``
* ``django.forms.util``
+* ``ModelAdmin.get_formsets`` will be removed.
+
2.0
---
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index dd31d11dee..2e02785e81 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -454,7 +454,7 @@ subclass::
.. attribute:: ModelAdmin.inlines
See :class:`InlineModelAdmin` objects below as well as
- :meth:`ModelAdmin.get_formsets`.
+ :meth:`ModelAdmin.get_formsets_with_inlines`.
.. attribute:: ModelAdmin.list_display
@@ -1365,7 +1365,10 @@ templates used by the :class:`ModelAdmin` views:
.. method:: ModelAdmin.get_formsets(self, request, obj=None)
- Yields :class:`InlineModelAdmin`\s for use in admin add and change views.
+ .. deprecated:: 1.7
+ Use :meth:`get_formsets_with_inlines()` instead.
+
+ Yields :class:`InlineModelAdmin`\s for use in admin add and change views.
For example if you wanted to display a particular inline only in the change
view, you could override ``get_formsets`` as follows::
@@ -1380,6 +1383,24 @@ templates used by the :class:`ModelAdmin` views:
continue
yield inline.get_formset(request, obj)
+.. method:: ModelAdmin.get_formsets_with_inlines(self, request, obj=None)
+
+ Yields (``FormSet``, :class:`InlineModelAdmin`) pairs for use in admin add
+ and change views.
+
+ For example if you wanted to display a particular inline only in the change
+ view, you could override ``get_formsets_with_inlines`` as follows::
+
+ class MyModelAdmin(admin.ModelAdmin):
+ inlines = [MyInline, SomeOtherInline]
+
+ def get_formsets_with_inlines(self, request, obj=None):
+ for inline in self.get_inline_instances(request, obj):
+ # hide MyInline in the add view
+ if isinstance(inline, MyInline) and obj is None:
+ continue
+ yield inline.get_formset(request, obj), inline
+
.. method:: ModelAdmin.formfield_for_foreignkey(self, db_field, request, **kwargs)
The ``formfield_for_foreignkey`` method on a ``ModelAdmin`` allows you to
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index 04ebb1596c..148da5af86 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -466,13 +466,13 @@ than simply ``myapp/models.py``, Django would look for :ref:`initial SQL data
will search ``myapp/sql/`` as documented. The old location will continue to
work until Django 1.9.
-``declared_fieldsets`` attribute on ``ModelAdmin.``
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+``declared_fieldsets`` attribute on ``ModelAdmin``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-``ModelAdmin.declared_fieldsets`` was deprecated. Despite being a private API,
-it will go through a regular deprecation path. This attribute was mostly used
-by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was considered
-a bug and has been addressed.
+``ModelAdmin.declared_fieldsets`` has been deprecated. Despite being a private
+API, it will go through a regular deprecation path. This attribute was mostly
+used by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was
+considered a bug and has been addressed.
``syncdb``
~~~~~~~~~~
@@ -491,3 +491,10 @@ to ``utils.py`` in an effort to unify all util and utils references:
* ``django.contrib.gis.db.backends.util``
* ``django.db.backends.util``
* ``django.forms.util``
+
+``get_formsets`` method on ``ModelAdmin``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+``ModelAdmin.get_formsets`` has been deprecated in favor of the new
+:meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
+better handle the case of selecting showing inlines on a ``ModelAdmin``.