Opened 8 years ago
Closed 7 years ago
#26763 closed New feature (fixed)
Control rendering of add/change/delete_related admin buttons
Reported by: | Chris Clark | Owned by: | Chris Clark |
---|---|---|---|
Component: | contrib.admin | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | yes |
Description (last modified by )
In certain cases, displaying the add/change/delete icons on related fields in the Django admin is undesirable, but this behavior can't currently be overridden. The proposed change allows configuration of which buttons to display by passing kwargs into formfield_for_db.
Attachments (2)
Change History (9)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|---|
Needs documentation: | set |
Needs tests: | set |
Owner: | changed from | to
Status: | new → assigned |
by , 8 years ago
Attachment: | Screen Shot 2016-06-15 at 9.42.18 AM.png added |
---|
comment:2 by , 8 years ago
Could you add some specifics about the use case? I'll admit I'm a bit fatigued about adding endless options in the admin to provide infinite customization.
comment:3 by , 8 years ago
For sure (and I hear you!). Essentially, the UI can be *incredibly* confusing in certain circumstances so we need to disable it.
Here's a very concrete example:
I've attached a screen shot from our Django admin site. We're an ecommerce company, and this is a customer's shipment with a "12% off" offer applied to it (the last field in the screenshot).
For various reasons, sometimes we need to remove the "offer" from a shipment. Our support reps get a call from a customer, go to the shipment in the Django admin and are *supposed* to set the drop down to --empty--, and save the shipment, in order to remove the offer.
Instead, a handful of times, reps have clicked the red X in order to 'remove' the offer from the shipment. A totally logical and reasonable thing to do, given the UI. But, of course, that deletes *the entire offer* from *the entire system*. The offer might be applied to hundreds, or thousands of different shipments, and disaster ensues.
The irony here is that, for safety, we have the FK field from Shipment -> Offer set as on_delete=set_null because god forbid deleting an offer also deleted all of the shipments. But set_null has the perverse side effect of actually ENABLING this X button; it's hidden in the presence of on_delete=cascade. Hah! (and there are other, valid, reasons to delete offers, and we would never want to delete shipments, so setting on_delete=cascade is not a solution for us here).
This type of UI confusion around these buttons occurs in a dozen or so spots around our admin interface.
comment:4 by , 8 years ago
I think it's also notable that the widget itself is already parameterized for this functionality, it's just that it was not carried through to the wrapper, which almost, if you squint and don't think about it too hard, looks like a bug.
comment:5 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:6 by , 8 years ago
Easy pickings: | unset |
---|
comment:7 by , 7 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
This was resolved by #27728, which allowed overriding admin templatetag's templates.
Screenshot of feature in question