Search code examples
djangoadminnon-ascii-characters

How to add actions to admin page with non-ascii charecters


I have this code which works fine in Django admin page, but is there a way to keep action name in Russian but function name in English?

actions = ["Отправить_сообщение"]  # add action to list page

def Отправить_сообщение(self, request, queryset):
    pass

cheers


Solution

  • Yes, see here: https://docs.djangoproject.com/en/3.0/ref/contrib/admin/actions/#writing-action-functions

    For your code:

    actions = ["my_action"]
    
    def my_action(self, request, queryset):
        pass
    
    my_action.short_description = "Отправить сообщение"
    

    Another way (better if you handle multiple languages) is to use the internationalization framework.