I am new to Django and am facing some issues with customizing a change_list
. I am trying to make a changelist column editable, AND change the column's display name. I managed to change the display name of the column by using a callable that returns the model field value, setting its short_description
property to the new column name and then adding the callable to the list_display
, which works fine. I then add the callable to the list_editable
, but then the editable field cannot get resolved. I get the error
The value of 'list_editable[0]' refers to 'get_instruction_date', which is not an attribute of 'employee.Onboarding'.
Is there a way to get this working (make column editable AND changing its display name/label) WITHOUT having to change the Model class itself? The model is being used elsewhere and field labels are set to meet that use case.
EDIT: So, I currently set the column name as suggested here, as such:
def get_instruction_date(self, obj):
return obj.instruction_date
get_instruction_date.short_description = 'Appointment'
list_display = ('get_instruction_date', 'instruction_done',...)
which works fine, but prevents me to make the column editable by adding it to the list_editable
list in the respective admin class.
list_editable = ('get_instruction_date', 'instruction_done')
throws the error I printed above.