Add input support to admin actions (with patch)
|Reported by:||Jerome Leclanche||Owned by:||Jerome Leclanche|
|Cc:||kmike84@…||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I wanted to be able to set tags to a lot of objects at once in the admin site.
The attached patch adds a takes_input attribute to an admin action (default False). If set to True, a 4th "input" argument will be passed, which you can use as such:
def add_tag(modeladmin, request, queryset, input): for obj in queryset: Tag.objects.add_tag(obj, input) add_tag.takes_input = True
I'd love some comments on it. Some TODO would be:
- Hiding the input if no give action takes an input
- js-disabling it if the current selected action doesn't take an input.. not too sure about that.
Change History (13)
comment:1 Changed 7 years ago by
|Patch needs improvement:||unset|