File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -1128,7 +1128,18 @@ templates used by the :class:`ModelAdmin` views:
1128
1128
``obj`` being edited (or ``None`` on an add form) and is expected to return
1129
1129
a ``list`` or ``tuple`` of :class:`~django.contrib.admin.InlineModelAdmin`
1130
1130
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.
1132
1143
1133
1144
.. method:: ModelAdmin.get_urls()
1134
1145
You can’t perform that action at this time.
0 commit comments