Hi,

A recent bug report [1] brought up the fact that ModelAdmin collects 
actions from superclasses. For example:

class BaseAdmin:
    actions = ['a']

class SubAdmin(BaseAdmin):
    actions = ['b']

SubAdmin will have action 'a' and 'b'. The behavior isn't tested and only 
mentioned in passing in docs for ModelAdmin.get_action(), "Most of the time 
you’ll use this method to conditionally remove actions from the list 
gathered by the superclass."

I think the reason for the "collect from superclasses" behavior was to 
inherit the "delete_selected" action from BaseModelAdmin, however, that 
reason was obsoleted in a later commit where AdminSite actions were added 
and delete_selected was moved there.

I propose removing this surprising (to me, at least) behavior and follow 
normal Python inheritance. If someone wants to inherit actions from a 
subclass, they should use:

class SubAdmin(BaseAdmin):
    actions = BaseAdmin.actions + ['b']

[1] https://code.djangoproject.com/ticket/29917
[2] 
https://github.com/django/django/commit/bb15cee58a43eeb0d060f8a31f9078b3406f195a

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/3235fe9c-30e2-4534-93eb-c7f6a45eac63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to