Opened 7 years ago

Closed 5 years ago

#27755 closed New feature (fixed)

add ModelAdmin.get_inlines() hook to allow set inlines based on the request or model instance.

Reported by: WeizhongTu Owned by: Hasan Ramezani
Component: contrib.admin Version: dev
Severity: Normal Keywords: django, admin, inlines
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

add ModelAdmin.get_inlines() hook to allow set inlines based on the request or model instance.
Currently, We can override the method get_inline_instances to do such a thing, but a for loop should be copied to my code. So I wished add a hook get_inlines(request, obj=None)

Change History (7)

comment:1 by Tim Graham, 7 years ago

Are you going to offer a patch to show exactly what you have in mind? I'm not immediately convinced that another hook is needed since the cost of duplicating a for loop is not that great.

in reply to:  1 comment:2 by WeizhongTu, 7 years ago

If I want to realize a dynamic inlines based on the request or model instance. I need to override get_inline_instances to do it.
What I want to do is just set self.inlines to dynamic values according to different person or object. not inline instances, so I advise to add a new hook get_inlines(request, obj=None) to finish such a thing.

I've created a new pull request here: ​https://github.com/django/django/pull/7920.

Last edited 7 years ago by Tim Graham (previous) (diff)

comment:3 by Tim Graham, 7 years ago

Has patch: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

I guess it's useful. The patch needs some improvement (tests, some doc fixes such as release notes) as per the PatchReviewChecklist.

comment:4 by Hidde Bultsma, 5 years ago

Owner: changed from nobody to Hidde Bultsma
Status: newassigned

comment:5 by Hasan Ramezani, 5 years ago

Owner: changed from Hidde Bultsma to Hasan Ramezani
Patch needs improvement: unset
Last edited 5 years ago by Tim Graham (previous) (diff)

comment:6 by Mariusz Felisiak, 5 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In 917fd9d0:

Fixed #27755 -- Added ModelAdmin.get_inlines() hook.

Note: See TracTickets for help on using tickets.
Back to Top