From d02f1ad71e86038ca4a8019d7d53caa29e098779 Mon Sep 17 00:00:00 2001 From: Matthias Schoettle Date: Fri, 24 Feb 2023 21:49:35 -0500 Subject: [PATCH] document hidden table attributes setting --- docs/pages/custom-rendering.rst | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/pages/custom-rendering.rst b/docs/pages/custom-rendering.rst index c7f26447..e061e488 100644 --- a/docs/pages/custom-rendering.rst +++ b/docs/pages/custom-rendering.rst @@ -25,12 +25,26 @@ a hook that allows arbitrary attributes to be added to the ```` tag. >>> # renders to something like this: '
...' +By default, django-tables2 looks for the ``DJANGO_TABLES2_TABLE_ATTRS`` +setting which allows you to define attributes globally for all tables. +For example, to have a Bootstrap5 table with hoverable rows +and a light table header define it as follows: + +.. sourcecode:: python + + DJANGO_TABLES2_TABLE_ATTRS = { + 'class': 'table table-hover', + 'thead': { + 'class': 'table-light', + }, + } + You can also specify ``attrs`` attribute when creating a column. ``attrs`` is a dictionary which contains attributes which by default get rendered on various tags involved with rendering a column. You can read more about them in :ref:`column-attributes`. django-tables2 supports three different dictionaries, this way you can give different attributes -to column tags in table header (``th``), rows (``td``) or footer (``tf``) +to column tags in table header (``th``), rows (``td``) or footer (``tf``). .. sourcecode:: python