Opened 10 years ago
Closed 8 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 |
Pull Requests: | |||
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:1 by , 10 years ago
comment:2 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:4 by , 10 years ago
Has patch: | set |
---|---|
Needs tests: | set |
comment:5 by , 9 years ago
Has patch: | unset |
---|---|
Needs tests: | unset |
Owner: | changed from | to
comment:7 by , 9 years ago
Patch needs improvement: | set |
---|
I left comments for improvement on the pull request.
comment:8 by , 8 years ago
Cc: | added |
---|
comment:10 by , 8 years ago
Patch needs improvement: | set |
---|
comment:11 by , 8 years ago
Patch needs improvement: | unset |
---|
comment:12 by , 8 years ago
Needs tests: | set |
---|
As noted on the PR, tests for the ModelAdmin.get_formsets()
changes are missing.
comment:13 by , 8 years ago
Needs tests: | unset |
---|
thread on django-developers.