We're seeing this with the qsessions app, which has to delete its session
objects in non-bulk mode in order to clear caches:
https://github.com/QueraTeam/django-
qsessions/blob/c21d602a50c4746da7f698a8d39317ef214e7d05/qsessions/admin.py#L41-L46
(For this particular use case, it seems a fix is to instead override
`modeladmin.delete_queryset` within `qsessions`'s `SessionAdmin`, as
that's what the built-in `delete_selected` action does per
https://github.com/django/django/blob/851d9eac23e08ff10a2d6fe5368b02798761663c/django/contrib/admin/actions.py#L40
.)
--
Ticket URL: <https://code.djangoproject.com/ticket/30311>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
This is [https://docs.djangoproject.com/en/2.2/releases/2.2/#admin-
actions-are-no-longer-collected-from-base-modeladmin-classes documented as
a backwards incompatible change in the 2.2 release notes].
See the discussion on #29917 and [https://groups.google.com/d/topic
/django-developers/-OWoYL_zryM/discussion the mailing list thread].
See [https://docs.djangoproject.com/en/2.2/ref/contrib/admin/actions
#adminsite-actions Making actions available site-wide] docs for the
suggested approach.
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:1>
* status: closed => new
* resolution: invalid =>
Comment:
Thanks! I did read the release notes, but the section linked has no
mention of global admin actions and it doesn't exactly apply, see below.
(Reopening for that reason.)
This issue only arises when
* a global action, say `expect_inquisition` (or the built-in default
`delete_selected`) has been defined, which is implicitly on every single
ModelAdmin
* that global action is still enabled
* and you attempt to explicitly add an action with the same `__name__` on
any given ModelAdmin class
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:2>
* status: new => closed
* resolution: => invalid
Comment:
Right, OK, gotcha.
Multiple defined actions with the same name are not supported. The system
check added in #29711 led directly to uncovering #29917, which had been
latent for many years.
As per the discussion on #29917, and the mailing list thread (that I
linked above), the decision was taken to adjust this behaviour.
You need to adjust your code to use site wide actions, or as an
alternative you can use subclassing, but now according to Python's normal
inheritance rules.
This was an example from the discussion:
{{{
class WithCustom(AdminBase):
actions = AdminBase.actions + ['custom_action']
}}}
You're free to adjust `actions` any way you need (at class, definition, in
`__init__()`, in `_get_base_actions()`, in `get_actions()`...) See the
[https://docs.djangoproject.com/en/2.2/ref/contrib/admin/actions
#disabling-admin-actions Disabling actions] section of the docs. There are
plenty of strategies there.
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:3>
* status: closed => new
* resolution: invalid =>
* stage: Unreviewed => Accepted
Comment:
Reopening based on mailing list discussion
https://groups.google.com/d/topic/django-developers/jDz-0wfowqg/discussion
Patch should at least consider whether we'll handle just `delete_selected`
or any action (`expect_inquisition` say).
(Original triage should have been `wontfix` rather than `invalid` looking
again.)
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:4>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/12591
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:6>
Comment (by אורי):
What is `delete_selected` and how do you use it? What are generic site-
wide actions?
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:7>
Comment (by hashlash):
Replying to [comment:7 אורי]:
> What is `delete_selected` and how do you use it? What are generic site-
wide actions?
`delete_selected` is a built-in Django's admin action. For more
information (including site-wide actions) please read the docs:
https://docs.djangoproject.com/en/2.2/ref/contrib/admin/actions/
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:8>
* version: 2.2 => master
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"dfbd9ca065728b543cc756359079a1b51d10841a" dfbd9ca0]:
{{{
#!CommitTicketReference repository=""
revision="dfbd9ca065728b543cc756359079a1b51d10841a"
Fixed #30311 -- Restored ability to override global admin actions.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:10>