mirror of
https://github.com/django/django.git
synced 2025-11-25 13:13:28 +00:00
Fixed #19425 - Added InlineModelAdmin.get_extra hook.
Thanks dave@ for the suggestion and Rohan Jain for the patch.
This commit is contained in:
parent
7902fd74f1
commit
36aecb12b8
6 changed files with 65 additions and 2 deletions
|
|
@ -129,6 +129,17 @@ class ChildModel1Inline(admin.TabularInline):
|
|||
class ChildModel2Inline(admin.StackedInline):
|
||||
model = ChildModel2
|
||||
|
||||
# admin for #19425
|
||||
class BinaryTreeAdmin(admin.TabularInline):
|
||||
model = BinaryTree
|
||||
|
||||
def get_extra(self, request, obj=None, **kwargs):
|
||||
extra = 2
|
||||
if obj:
|
||||
return extra - obj.binarytree_set.count()
|
||||
|
||||
return extra
|
||||
|
||||
# admin for #19524
|
||||
class SightingInline(admin.TabularInline):
|
||||
model = Sighting
|
||||
|
|
@ -150,4 +161,5 @@ site.register(Author, AuthorAdmin)
|
|||
site.register(CapoFamiglia, inlines=[ConsigliereInline, SottoCapoInline, ReadOnlyInlineInline])
|
||||
site.register(ProfileCollection, inlines=[ProfileInline])
|
||||
site.register(ParentModelWithCustomPk, inlines=[ChildModel1Inline, ChildModel2Inline])
|
||||
site.register(BinaryTree, inlines=[BinaryTreeAdmin])
|
||||
site.register(ExtraTerrestrial, inlines=[SightingInline])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue