问题
In Django 1.8.6, by default, whenever I provide a list_display
option to a ModelAdmin subclass, the first field in the list becomes clickable and leads to the object edit page.
Is there a way to keep the order of the fields in list_display
, but change the clickable one?
Currently, I have the id
field clickable (it goes first in list_display
), which is a tad small. I would like to better click on, say, name
to go to the edit page.
回答1:
You could have a look at django.contrib.admin.ModelAdmin.list_display_links
Basically it is used like
class PersonAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'birthday')
list_display_links = ('first_name', 'last_name')
Hope this will help :)
来源:https://stackoverflow.com/questions/33616330/change-clickable-field-in-django-admin-list-display