Hello everyone!
So, I want to render a table with django_tables2.
I can accomplish the render of the table correctly but I can’t modify which fields are included or excluded.
On the shell I can get what I want but I don’t know how to integrate that table into SingleTableView
maintaining the exclusion.
In [1] class ClientTable(tables.Table):
...: class Meta:
...: model = Client
...: fields = ("name", )
In [2]: ClientTable.base_columns
Out[2]:
OrderedDict([('name',
<django_tables2.columns.base.Column at 0x7f78f8033730>)])
views.py
With this example the table renders correctly but it doesn’t exclude any fields from the Client
model. Docs
class ClientTable(tables.Table):
class Meta:
model = Client
exclude = ("id", )
# Also tried with fields = ("name", "surname", )
class ClientListView(tables.SingleTableView):
model = Client
table_class = ClientTable
template_name = "clients/clients.html"
Thanks in advance!