Search code examples
pythondjangodjango-admindjango-admin-actions

Django Admin action different names then function names


Is possible to have action display in Django Admin with a different name than its function name?

for example:


 def an_action():
   pass

class AdminPanel(admin.ModelAdmin):
   actions = [ an_action]

In the Django admin panel an_action would display as "An action". Could I made this display something arbitrary like "Best Action Ever" instead of "An Action"?


Solution

  • Try this:

    def an_action():
       pass
    an_action.short_description = 'my label'
    
    class AdminPanel(admin.ModelAdmin):
       actions = [an_action]