Opened 9 years ago

Closed 7 years ago

#24941 closed New feature (fixed)

Add get_exclude() hook to BaseModelAdmin

Reported by: Peter J. Farrell Owned by: Zach Borboa
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: zborboa@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

TL;DR: Most attributes in the admin have get_XXX() hooks however exclude is missing this functionality. This ticket is to add get_exclude() hook to so it matches the same pattern of hooks the rest of the admin has.

I have a patch in the works if accepted.
--

We're building out a custom admin base for CleanerVersion in which we subclass ModelAdmin. We needed to dynamically get the developer's choices in exclude and add in our own without overwriting the developer's settings in their concrete class. Just about all other attributes have their own hook method in order to get at attribute values, but exclude seems to be the only one that is doesn't follow this pattern.

It is possible to "mock" this without having to override bunch of other methods by using a @property descriptor, but this causes the admin checks to throw an error when performing the check on exclude. This is monkey patched by subclassing the admin checks class and overriding the check for exclude. Less than ideal.

Simple solution is add an get_exclude() method to the BaseModelAdmin so it offers the same hook methods that are available for list_display, fields, etc.

Change History (14)

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Sujay S Kumar, 9 years ago

Owner: changed from nobody to Sujay S Kumar
Status: newassigned

comment:4 by Sujay S Kumar, 9 years ago

Has patch: set
Needs tests: set

comment:5 by Ola Sitarska, 9 years ago

Has patch: unset
Needs tests: unset
Owner: changed from Sujay S Kumar to Ola Sitarska

comment:6 by Ola Sitarska, 9 years ago

Has patch: set

comment:7 by Tim Graham, 9 years ago

Patch needs improvement: set

I left comments for improvement on the pull request.

comment:8 by Zach, 8 years ago

Cc: zborboa@… added

comment:9 by Zach Borboa, 7 years ago

Owner: changed from Ola Sitarska to Zach Borboa
Patch needs improvement: unset

comment:10 by Tim Graham, 7 years ago

Patch needs improvement: set

comment:11 by Tim Graham, 7 years ago

Patch needs improvement: unset

comment:12 by Tim Graham, 7 years ago

Needs tests: set

As noted on the PR, tests for the ModelAdmin.get_formsets() changes are missing.

comment:13 by Tim Graham, 7 years ago

Needs tests: unset

comment:14 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In bf91be83:

Fixed #24941 -- Added ModelAdmin.get_exclude().

Thanks Ola Sitarska for the initial patch.

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