In the tables.py in the example dir there is:
class Bootstrap4Table(tables.Table):
country = tables.Column(linkify=True)
continent = tables.Column(accessor="country__continent", linkify=True)
class Meta:
model = Person
template_name = "django_tables2/bootstrap4.html"
attrs = {"class": "table table-hover"}
exclude = ("friendly",)
I am trying to create a table class dynamically, so I did: Override the get_table method like so:
def get_table(self, **kwargs):
"""
Return a table object to use. The table has automatic support for
sorting and pagination.
"""
table_class, table_data = type('QueryTable', (tables.Table), myTableCol), mylist
table_class = table_class
print(table_class, table_data)
table = table_class(data=table_data, **kwargs)
return RequestConfig(self.request, paginate=self.get_table_pagination(table)).configure(table)
Where the table_class, table_data is where I am creating the class. myTableCol provides the columns and mylist provides the data for each column. My problem is I dont know how to include the template_name = "django_tables2/bootstrap4.html" when I am dynamically creating the table class. Also, when i do it this way, the tables dont show any borders.
I am pulling data from a rdf graph and I don't know the name or number of columns, so I want to dynamically create the columns along with having the Meta class with template_name = "django_tables2/bootstrap4.html.