8000 [1.5.x] Added warning about get_inline_instances() permission checkin… · ddriddle/django@17ffd24 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17ffd24

Browse files
charettestimgraham
authored andcommitted
[1.5.x] Added warning about get_inline_instances() permission checking; refs #23754.
Backport of e0d1f26 from master
1 parent da3a23a commit 17ffd24

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/ref/contrib/admin/index.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,18 @@ templates used by the :class:`ModelAdmin` views:
11281128
``obj`` being edited (or ``None`` on an add form) and is expected to return
11291129
a ``list`` or ``tuple`` of :class:`~django.contrib.admin.InlineModelAdmin`
11301130
objects, as described below in the :class:`~django.contrib.admin.InlineModelAdmin`
1131-
section.
1131+
section. For example, the following would return inlines without the default
1132+
filtering based on add, change, and delete permissions::
1133+
1134+
class MyModelAdmin(admin.ModelAdmin):
1135+
inlines = (MyInline,)
1136+
1137+
def get_inline_instances(self, request, obj=None):
1138+
return [inline(self.model, self.admin_site) for inline in self.inlines]
1139+
1140+
If you override this method, make sure that the returned inlines are
1141+
instances of the classes defined in :attr:`inlines` or you might encounter
1142+
a "Bad Request" error when adding related objects.
11321143

11331144
.. method:: ModelAdmin.get_urls()
11341145

0 commit comments

Comments
 (0)
0