3 | | what I've done in my custom admin_list.py implementation is the following: |
4 | | |
5 | | {{{ |
6 | | list_column_classes = getattr(cl.model_admin, 'list_column_classes', {}) |
7 | | |
8 | | for field_name in cl.list_display: |
9 | | # .... |
10 | | |
11 | | row_classes.append(list_column_classes.get(field_name, 'col-' + field_name)) |
12 | | }}} |
13 | | |
14 | | This also allows the developers to define a `list_column_classes` attribute on a `ModelAdmin` |
15 | | |
16 | | Getting the HTML size trimmed down is one thing. |
17 | | Having an admin list with badly formatted column widths is far worse for clients. |
18 | | I'd really like to see something like this by default in Django, to stop DRY implementations. |
| 3 | * Allows the developers to define a `list_column_classes` attribute on a `ModelAdmin`, in case they need to specify a class. |
| 4 | * Only when it's really needed, the class has to be added. |
| 5 | * Define a default class in the `thead`. This allows changing column widths. |
| 6 | * People can adjust the column widths easily, without having many extra classes in the HTML. |