I'm trying to rename the IS STAFF
to STAFF STATUS
here:
I'm just wondering if it's possible to rename it from
admin.py
& NOT use the verbose_name
inside the model.
I wrote this code in admin.py
:
@admin.register(User)
class CustomUserAdmin(DefaultUserAdmin):
list_display = [
'username',
'RENAMED_EMAIL',
'first_name',
'last_name',
'RENAMED_STAFF',
'is_active',
]
@admin.display(description="EMAIL ADDRESS", ordering='-email')
def RENAMED_EMAIL(self, obj):
return obj.email
@admin.display(
description="STAFF STATUS",
boolean=True,
ordering='-is_staff',
)
def RENAMED_STAFF(self, obj):
return obj.is_staff
list_editable = ['is_staff', 'is_active']
The EMAIL ADDRESS was renamed successfully but as I used is_staff
in list_editable
, I get this error:
ERRORS:
<class 'accounts.admin.CustomUserAdmin'>: (admin.E122) The value of 'list_editable[0]' refers to 'is_staff', which is
not contained in 'list_display'.
Tried to use RENAMED_STAFF
inside list_editable
too, it results in another error:
ERRORS:
<class 'accounts.admin.CustomUserAdmin'>: (admin.E121) The value of 'list_editable[0]' refers to 'RENAMED_STAFF', which is not a field of 'accounts.User'.
What is the proper way to customize those column names?