On Wed, 18 Mar 2020 09:29:17 -0700 (PDT)
charettes <charett...@gmail.com> wrote:

> Just to make the above clear, here's what I had in mind
> 
> https://gist.github.com/charettes/a0cb94242ac9c198625b23f4f55fab45
> 
> Le mercredi 18 mars 2020 12:20:54 UTC-4, charettes a écrit :
> >
> > Given the common need to override delete_selected I wonder if we
> > could define it as ModelAdmin method and use a .actions string
> > reference to it in the AdminSite instead[0].
> >
> > That would allow admin classes to simply override the
> > delete_selected method on their admin classes without having to
> > resort to redefining .actions which seems to trigger the issue here.
> >
> > Cheers,
> > Simon
> >
> > [0] 
> > https://github.com/django/django/blob/d4df5e1b0b1c643fe0fc521add0236764ec8e92a/django/contrib/admin/sites.py#L66
> >
> > Le mercredi 18 mars 2020 12:01:15 UTC-4, Shai Berger a écrit :  
> >>
> >> Hello fellow Djangonauts, 
> >>
> >> While working on upgrading a project to 2.2, I ran into multiple 
> >> instances of 
> >>
> >>         <class '...Admin'>: (admin.E130) __name__ attributes of
> >> actions defined in <class '...Admin'> must be unique. 
> >>
> >> caused by the fact that, out of a large set of Admin classes,
> >> about a dozen have defined their own version of the
> >> 'delete_selected' action. 
> >>
> >> When looking into it, I came across ticket #30311[1] which
> >> basically complained about the very same thing; but was closed as
> >> invalid, under the claim that the user is in full control of both
> >> the site-wide actions and the admin-specific actions, and so can
> >> do whatever they like. 
> >>
> >> While that claim is certainly correct, I would like to suggest
> >> that it creates an odd situation for the app which wants to define
> >> its own version of delete_selected (or any other
> >> site-wide-availabe action) for one of its models. In fact, it now
> >> cannot be done at the app level -- it requires that the default
> >> action be disabled at the site level. 
> >>
> >> If (as is probably the case with delete_selected) it is still
> >> desired as a site-wide-available action, then the default needs to
> >> be replaced with a custom action which first looks for an override
> >> on the specific admin, and if not found invokes the original. And
> >> that seems to me like a hoop we shouldn't force people to jump
> >> through. 
> >>
> >> Opinions? 
> >>
> >> [1] https://code.djangoproject.com/ticket/30311 
> >>  
> >  
> 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/20200318185115.680d4e22.shai%40platonix.com.

Reply via email to