#34724: Allow passing kwargs to django.contrib.admin.decorators.display
--------------------------------------------+------------------------
               Reporter:  Abdullah Alaqeel  |          Owner:  nobody
                   Type:  New feature       |         Status:  new
              Component:  contrib.admin     |        Version:  dev
               Severity:  Normal            |       Keywords:
           Triage Stage:  Unreviewed        |      Has patch:  0
    Needs documentation:  0                 |    Needs tests:  0
Patch needs improvement:  0                 |  Easy pickings:  1
                  UI/UX:  0                 |
--------------------------------------------+------------------------
 There are many packages that depend on assigning custom params to
 ModelAdmin methods. One package we use regularly is
 [https://github.com/lukasvinclav/django-admin-actions django-admin-
 actions] which requires writing something like:

 {{{
 @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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701896f65dfdf-c18c4487-7450-4e5f-be63-fad81ff5ef93-000000%40eu-central-1.amazonses.com.

Reply via email to