def get_datatables(self, only=None):
        """ Returns a dict of the datatables served by this view. """
        if not hasattr(self, '_datatables'):
            self._datatables = {}
            datatable_classes = self.get_datatable_classes()
            for name, datatable_class in datatable_classes.items():
                if only and name != only:
                    continue
                queryset_getter_name = 'get_%s_datatable_queryset' % (name,)
                queryset_getter = getattr(self, queryset_getter_name, None)
                if queryset_getter is None:
                    raise ValueError("%r must declare a method %r." % (self.__class__.__name__,
                                                                       queryset_getter_name))

                queryset = queryset_getter()
                if datatable_class is None:
                    class AutoMeta:
                        model = queryset.model
                    datatable_class = type('%sDatatable' % (self.__class__.__name__,), (Datatable,), {
                        'Meta': AutoMeta,
                    })
                elif datatable_class._meta.model is None:
                    opts = datatable_class.options_class(datatable_class._meta)
                    opts.model = queryset.model
                    datatable_class = type('%s_WithModel' % (datatable_class.__name__,), (datatable_class,), {
                        'Meta': opts,
                    })

                default_kwargs = {
                    'object_list': queryset,
                }
                kwargs_getter_name = 'get_%s_datatable_kwargs' % (name,)
                kwargs_getter = getattr(self, kwargs_getter_name, self.get_default_datatable_kwargs)
                kwargs = kwargs_getter(**default_kwargs)
                if 'url' in kwargs:
                    kwargs['url'] = kwargs['url'] + "?datatable=%s" % (name,)
                self._datatables[name] = datatable_class(**kwargs)
        return self._datatables
dataset/ETHPy150Open pivotal-energy-solutions/django-datatable-view/datatableview/views/base.py/MultipleDatatableMixin.get_datatables/original