Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give a column in the Django admin change_list a CSS class

I'd like to change the column widths in the list display of the Django admin.

Is it possible somehow to add a CSS classname to a column? I'd preferably not overwrite the entire template to accomplish this.

like image 820
vdboor Avatar asked Apr 21 '11 10:04

vdboor


Video Answer


1 Answers

In Django >= 1.6, CSS classes are included with list_display output:

"The field names in list_display will also appear as CSS classes in the HTML output, in the form of column-<field_name> on each <th> element. This can be used to set column widths in a CSS file."

like image 154
StvnW Avatar answered Nov 10 '22 00:11

StvnW