Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Admin: How to display more fields as links?

The default admin page for Django automatically makes the first heading of each table a link to edit the information (see below):

enter image description here

Clicking the ID column data will take you to a page to edit the fields in the selected table, in this case Applicants

Is there a way of changing this setup, so that Surname is the link to edit and not ID?

Many Thanks.

like image 908
Jon Avatar asked Oct 29 '25 00:10

Jon


1 Answers

Use list_displays_links to control if and which fields in list_display should be linked to the edit page for an object.

Example usage:

class PersonAdmin(admin.ModelAdmin):
    list_display = ('first_name', 'surname', 'location')
    list_display_links = ('first_name', 'surname')

...would make both first_name and surname clickable.

like image 177
rnevius Avatar answered Oct 30 '25 16:10

rnevius