Django Admin,如何更换用户状态标志

Django Admin, how to replace the user status sign

在django admin中,超级用户栏,显示这两个标志

如何用文本替换它们?

您可以定义一个模型管理方法,returns 您需要的文本,然后将其包含在 list_display 中。

class MyUserAdmin(UserAdmin):
    def is_superuser_text(self, obj):
        return 'True' if obj.is_superuser else 'False'            
    is_superuser_text.short_description = 'Is Superuser'
    is_superuser_text.admin_order_field = 'is_superuser'

    list_display = ('username', 'first_name', 'email', 'date_joined', 'is_superuser_text',)