summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-03-19 16:13:26 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-04-17 07:16:04 +0200
commit917fd9d03fdd21538864af4b412ac30b36d99268 (patch)
treeba9a1b26cac9b7a8c5f8258e00ac4f1832bef26a /docs
parent7d49ad76562e8c0597a0eb66046ab423b12888d8 (diff)
Fixed #27755 -- Added ModelAdmin.get_inlines() hook.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/admin/index.txt10
-rw-r--r--docs/releases/3.0.txt4
2 files changed, 14 insertions, 0 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index 93679c46fd..e6bb91cf5c 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -1627,6 +1627,16 @@ templates used by the :class:`ModelAdmin` views:
instances of the classes defined in :attr:`inlines` or you might encounter
a "Bad Request" error when adding related objects.
+.. method:: ModelAdmin.get_inlines(request, obj)
+
+ .. versionadded:: 3.0
+
+ The ``get_inlines`` method is given the ``HttpRequest`` and the
+ ``obj`` being edited (or ``None`` on an add form) and is expected to return
+ an iterable of inlines. You can override this method to dynamically add
+ inlines based on the request or model instance instead of specifying them
+ in :attr:`ModelAdmin.inlines`.
+
.. method:: ModelAdmin.get_urls()
The ``get_urls`` method on a ``ModelAdmin`` returns the URLs to be used for
diff --git a/docs/releases/3.0.txt b/docs/releases/3.0.txt
index d7ad7a8cf7..44656b11cd 100644
--- a/docs/releases/3.0.txt
+++ b/docs/releases/3.0.txt
@@ -47,6 +47,10 @@ Minor features
* Added support for the ``admin_order_field`` attribute on properties in
:attr:`.ModelAdmin.list_display`.
+* The new :meth:`ModelAdmin.get_inlines()
+ <django.contrib.admin.ModelAdmin.get_inlines>` method allows specifying the
+ inlines based on the request or model instance.
+
:mod:`django.contrib.admindocs`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~