{{{
@admin.register(ExampleModel)
class CustomAdmin(ActionsModelAdmin):
actions_list = ('custom_list_action', )
def custom_list_action(self, request):
# custom logic here
return redirect(reverse_lazy('admin:APP_MODEL_changelist'))
custom_list_action.short_description = _('Custom name')
custom_list_action.url_path = 'clean-url-path-1'
}}}
However, when using django.contrib.admin.decorators.display, it will be:
{{{
@admin.register(ExampleModel)
class CustomAdmin(ActionsModelAdmin):
actions_list = ('custom_list_action', )
@admin.display(description=_('Custom name'))
def custom_list_action(self, request):
# custom logic here
return redirect(reverse_lazy('admin:APP_MODEL_changelist'))
custom_list_action.url_path = 'clean-url-path-1'
}}}
It would be really helpful/clean if we can pass any kwargs we want to the
decorator, so that the code looks like:
{{{
@admin.register(ExampleModel)
class CustomAdmin(ActionsModelAdmin):
actions_list = ('custom_list_action', )
@admin.display(description=_('Custom name'), url_path='clean-url-
path-1')
def custom_list_action(self, request):
# custom logic here
return redirect(reverse_lazy('admin:APP_MODEL_changelist'))
}}}
I know that creating a custom decorator (either by the users or the
package maintainers) is trivial but I think there is value to the
community to add the kwargs support natively.
--
Ticket URL: <https://code.djangoproject.com/ticket/34724>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* cc: Nick Pope (added)
* status: new => closed
* resolution: => wontfix
* easy: 1 => 0
Comment:
> I know that creating a custom decorator (either by the users or the
package maintainers) is trivial but I think there is value to the
community to add the kwargs support natively.
Thanks for the ticket, however I don't agree. Custom `kwargs` need to be
handled somehow, and Django (i.e. `@admin.display`) will not handle them
for users, which can cause confusion (check out #20744).
--
Ticket URL: <https://code.djangoproject.com/ticket/34724#comment:1>