-
Notifications
You must be signed in to change notification settings - Fork 436
Open
Description
The get_table_kwargs()
method allows to pass parameters when constructing a table instance:
django-tables2/django_tables2/views.py
Lines 141 to 153 in b0040fc
def get_table_kwargs(self): | |
""" | |
Return the keyword arguments for instantiating the table. | |
Allows passing customized arguments to the table constructor, for example, | |
to remove the buttons column, you could define this method in your View:: | |
def get_table_kwargs(self): | |
return { | |
'exclude': ('buttons', ) | |
} | |
""" | |
return {} |
and a Table
can work with a request
parameter:
django-tables2/django_tables2/tables.py
Lines 255 to 276 in b0040fc
def __init__( | |
self, | |
data=None, | |
order_by=None, | |
orderable=None, | |
empty_text=None, | |
exclude=None, | |
attrs=None, | |
row_attrs=None, | |
pinned_row_attrs=None, | |
sequence=None, | |
prefix=None, | |
order_by_field=None, | |
page_field=None, | |
per_page_field=None, | |
template_name=None, | |
default=None, | |
request=None, | |
show_header=None, | |
show_footer=True, | |
extra_columns=None, | |
): |
It thus looks straightforward to pass the request, by default, to the Table
such that the table can implement logic based on that request.
While the RequestConfig
also injects the request
object into the Table
, that means it is not available at the time the __init__
function is called on the table, and people might try to generate a table without the RequestConfig
.
Metadata
Metadata
Assignees
Labels
No labels