Live demo

Pretty name headline


Description

Default ordering is normally controlled by the model's Meta option ordering, which is a list of field names (possibly with a prefix "-" character to denote reverse order).

datatable_options["ordering"] is the same kind of list, with the exception that it should target virtual and compound fields by their "pretty name", which is the first item in the column definition tuple.



Implementation in code

        
    class OrderingDatatableView(DatatableView):
        model = Entry
        datatable_options = {
            'columns': [
                'id',
                'headline',
            ],
            'ordering': ['-id'],
        }