Live demo

ID headline blog Publication date


Description

The default template used by the datatable context variable when you render it will include data-name attributes on the <th> column headers, which is the slugify'd version of the column's label. This makes sizing the columns very easy.

<style type="text/css">
.datatable th[data-name="publication-date"] {
    width: 8%;
}
</style>
    


Implementation in code

        
    class CSSStylingDatatableView(DatatableView):
        model = Entry
        datatable_options = {
            'columns': [
                'id',
                'headline',
                'blog',
                'pub_date',
            ],
        }