I agree, it shouldn’t be doing something so surprising and undocumented. On Mon, 5 Nov 2018 at 17:03, Tim Graham <timogra...@gmail.com> wrote:
> 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 > <https://groups.google.com/d/msgid/django-developers/3235fe9c-30e2-4534-93eb-c7f6a45eac63%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Adam -- 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/CAMyDDM3hPSFtsVVGkJVann25BaXe60LGuxcVw04%2B0MVp7LYKZw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.