I suggest adding a new option to write actions which does not need objects to be selected. For example we want to add an action to reset a reminder flag for all existing objects. But if you haven’t selected any objects, it does not work and shows you the message, that no objects were selected.
A possible non-breaking option could be to add a new optional parameter to the @admin.action() decorator to deactivate the previously mentioned behavior.
Alternative with a new field, e. g. “extended_actions”:
https://gist.github.com/rafen/eff7adae38903eee76600cff40b8b659
Ticket:
https://code.djangoproject.com/ticket/35611
Hi @Zerotask.
The Admin API is already quite extensive. I’m a little sceptical about extending it further (for this use-case, at least).
I wonder if you can’t achieve what you’re after by subclassing the ActionForm
class to set select_across
in clean if your particular action is selected, thereby removing the requirement to select a particular item. (You’d likely ignore the passed queryset in your action itself.)
That’s not documented API, but it seems quite minimal, and wouldn’t require any change in Django (or the long wait for that to be released).
I think you might find the django-no-queryset-admin-actions package interesting. I recently created it to make it possible to have actions that do not require queryset. In future I may add a option for actions that received queryset optionally.