Masscrits
Masscrits

Reputation: 77

How to make a column sortable and clickable the Django Admin?

Hey I have a model UserProfile which has a OneToOneField relationship to the model User. In the adminpage I use list_display property to display some of the fields of UserProfile in the same place where User is displayed. They are displayed well but unfortunately they are not sortable like the models from User. I can click on the column heading in order to sort the columns which belong to User but not the ones that are from UserProfile how do you make them clickable and sortable?

Upvotes: 4

Views: 10685

Answers (1)

Brandon Taylor
Brandon Taylor

Reputation: 34553

You'll need to add the admin_order_field property to your columns.

Upvotes: 8

Related Questions