Django admin change_list: Change multiple column names -


i want change multiple column names in list_display. attribute function using short_description shown here: django admin listview customize column name. however, sounds not practical if want change around 25 column headers.

is there more efficient way?

first workable approach generate 25 attribute functions in admin init method. implemented easier approach using mapping dictionary , for-loop in javascript:

function shorten_column_headers() {    var headers = {      'list_display_field_name_1': 'shortened description_1',      'list_display_field_name_2': 'shortened description_2',      ...    }    (var field in headers) {      var $col = $('th.column-' + field + '> div.text > a:nth-child(1)');      $col.text(headers[field]);    }  }    $(document).ready(function() {    shorten_column_headers();  });


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -