Live demo

ID Headline


Simple columns might only need one model field to represent their data, even when marked up by a callback function. However, if a column actually represents more than one model field, the list of those fields can be given in place of a single field name.

You'll probably want to use a callback in order to decide how these values should be sorted out. The default strategy if no callback is supplies is to join the values with " ". The utility of this might be limited, but it's a reasonable default to give you a starting point.

Compound columns should target fields, not merely foreign keys. For example, you might indeed want the unicode( representation to appear in the marked-up column data, but be sure to target the specific fields on Blog that are represented in that display.

Specifying all of the relevent fields in a compound column helps make searching and sorting more natural. Sorting a compound column is the same as giving the field list to a call to the queryset order_by() method.

Implementation in code

        class CompoundColumnDatatableView(DatatableView):
            model = Entry
            datatable_options = {
                'columns': [
                    ("Headline", ['headline', 'blog__name'], 'get_headline_data'),

            def get_headline_data(self, instance, *args, **kwargs):
                return "%s (%s)" % (instance.headline,