[Django] #30311: Can't replace global admin actions with specialized ones per-admin

22 views
Skip to first unread message

Django

unread,
Apr 2, 2019, 9:42:58 AM4/2/19
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-----------------------------------------+------------------------
Reporter: Aarni Koskela | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
f9ff1df1daac8ae1fc22b27f48735148cb5488dd landed in 2.2 (discussion in
#29917), which makes it impossible to replace a generic site-wide action
(such as the built-in `delete_selected`) with a new one. It fails with the
admin.E130 system check error.

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.

Django

unread,
Apr 2, 2019, 10:50:31 AM4/2/19
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------+--------------------------------------

Reporter: Aarni Koskela | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Apr 3, 2019, 7:48:57 AM4/3/19
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------+--------------------------------------

Reporter: Aarni Koskela | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Aarni Koskela):

* 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>

Django

unread,
Apr 5, 2019, 6:21:51 AM4/5/19
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------+--------------------------------------

Reporter: Aarni Koskela | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Mar 19, 2020, 10:06:45 AM3/19/20
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------+------------------------------------

Reporter: Aarni Koskela | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Carlton Gibson):

* 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>

Django

unread,
Mar 20, 2020, 4:10:54 AM3/20/20
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------+------------------------------------
Reporter: Aarni Koskela | Owner: hashlash
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by hashlash):

* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/12591

--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:6>

Django

unread,
Mar 20, 2020, 11:55:52 AM3/20/20
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------+------------------------------------
Reporter: Aarni Koskela | Owner: hashlash
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

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>

Django

unread,
Mar 20, 2020, 4:33:06 PM3/20/20
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------+------------------------------------
Reporter: Aarni Koskela | Owner: hashlash
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

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>

Django

unread,
Apr 17, 2020, 7:02:33 AM4/17/20
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------------+-------------------------------------

Reporter: Aarni Koskela | Owner: hashlash
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* version: 2.2 => master
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/30311#comment:9>

Django

unread,
Apr 17, 2020, 4:45:05 PM4/17/20
to django-...@googlegroups.com
#30311: Can't replace global admin actions with specialized ones per-admin
-------------------------------------+-------------------------------------
Reporter: Aarni Koskela | Owner: hashlash
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* 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>

Reply all
Reply to author
Forward
0 new messages