Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#10596 closed (fixed)

There should be a better way to remove the actions provided by parent classes

Reported by: ElliottM Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: admin bulk default
Cc: kmike84@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The people who use my admin site have very clear instructions to set "is_active" to false rather than deleting users. I obviously trust them if I'm giving them superuser access, but at the same time I don't think it's a good idea to put in even larger shiny red button and keep telling them not to press it; the current delete button is red and shiny enough as it is.

In fact, only one of the several models that are managed via my admin site are ever deleted via the admin, and there are so few of those models at a time that bulk deletion isn't necessary.

I therefore want the "delete selected items" to not be enabled by default, or I want an option in the modeladmin to disable a given global action for this model, or preferably both.

Change History (7)

comment:1 Changed 9 years ago by Alex Gaynor

Resolution: duplicate
Status: newclosed

This can currently be done by overiding get_actions() to remove the 'delete_selected' option(or whatever ones you want to remove. There's also #10595

comment:2 Changed 9 years ago by ElliottM

That's not documented though. Get_actions isn't mentioned once in the admin actions documentation page.

comment:3 Changed 9 years ago by Jacob

milestone: 1.1
Resolution: duplicate
Status: closedreopened
Summary: There should be a way to remove the "Delete selected items" bulk admin action.There should be a better way to remove the actions provided by parent classes
Triage Stage: UnreviewedAccepted
Version: 1.0-beta-1SVN

Reopened with a better, more general title; I agree this needs to be fixed for the feature to be generally usable.

comment:4 Changed 9 years ago by cornbread

I completely agree with this. I think it's necessary.

comment:5 Changed 9 years ago by Mikhail Korobov

Cc: kmike84@… added

comment:6 Changed 9 years ago by Jacob

Resolution: fixed
Status: reopenedclosed

(In [10408]) Made a bunch of improvements to admin actions. Be warned: this includes one minor but BACKWARDS-INCOMPATIBLE change.

These changes are:

  • BACKWARDS-INCOMPATIBLE CHANGE: action functions and action methods now share the same signature: (modeladmin, request, queryset). Actions defined as methods stay the same, but if you've defined an action as a standalone function you'll now need to add that first modeladmin argument.
  • The delete selected action is now a standalone function registered site-wide; this makes disabling it easy.
  • Fixed #10596: there are now official, documented AdminSite APIs for dealing with actions, including a method to disable global actions. You can still re-enable globally-disabled actions on a case-by-case basis.
  • Fixed #10595: you can now disable actions for a particular ModelAdmin by setting actions to None.
  • Fixed #10734: actions are now sorted (by name).
  • Fixed #10618: the action is now taken from the form whose "submit" button you clicked, not arbitrarily the last form on the page.
  • All of the above is documented and tested.

comment:3 Changed 7 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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