Live demo

ID headline blog


Care must be taken to modify the options object on the View class: because it is defined as a class attribute, there is only one copy of it in memory, and changing it is not thread safe.

To safely change the options at runtime, copy the main options dictionary and then make a deep of the columns list (copying the outer dictionary will not do this automatically). The simplest way to do this is via a call to the built-in copy.deepcopy function.

Implementation in code

    class PerRequestOptionsDatatableView(DemoMixin, DatatableView):
        model = Entry
        datatable_options = {
            'columns': [

        def get_datatable_options(self):
            from copy import deepcopy
            options = deepcopy(self.datatable_options)
            return options