Home > database >  How can I change titles in action section in Django admin panel?
How can I change titles in action section in Django admin panel?

Time:01-23

I want to change titles in action section in Django admin. How can I do that? enter image description here

CodePudding user response:

The description [GitHub] is defined in the django.contrib.admin.actions module with:

@action(
    permissions=["delete"],
    description=gettext_lazy("Delete selected %(verbose_name_plural)s"),
)
def delete_selected(modeladmin, request, queryset):
    # …

It takes the verbose_name_plural of the model. You thus can change the verbose_name_plural with:

class Article(models.Model):
    # …

    class Meta:
        verbose_name_plural = 'publications'
        # …

or you can make a translation file that translates it to something else, but you are limited to what the Django modeladmin passes to the formatter.

  • Related