From 2fa2f24447980fa946ba17191ba260407f2a036b Mon Sep 17 00:00:00 2001 From: Matthias Schoettle Date: Sun, 5 Mar 2023 09:02:04 -0500 Subject: [PATCH] Add bootstrap5-responsive.html template and update docs (#896) --- .../django_tables2/bootstrap5-responsive.html | 13 +++++++++ docs/pages/custom-rendering.rst | 27 ++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 django_tables2/templates/django_tables2/bootstrap5-responsive.html diff --git a/django_tables2/templates/django_tables2/bootstrap5-responsive.html b/django_tables2/templates/django_tables2/bootstrap5-responsive.html new file mode 100644 index 00000000..d5580b6e --- /dev/null +++ b/django_tables2/templates/django_tables2/bootstrap5-responsive.html @@ -0,0 +1,13 @@ +{% extends 'django_tables2/bootstrap4.html' %} + +{% block table-wrapper %} +
+ {% block table %} + {{ block.super }} + {% endblock table %} + + {% block pagination %} + {{ block.super }} + {% endblock pagination %} +
+{% endblock table-wrapper %} diff --git a/docs/pages/custom-rendering.rst b/docs/pages/custom-rendering.rst index e061e488..d0921e68 100644 --- a/docs/pages/custom-rendering.rst +++ b/docs/pages/custom-rendering.rst @@ -68,23 +68,26 @@ Available templates We ship a couple of different templates: -======================================== ====================================================== -Template name Description -======================================== ====================================================== -django_tables2/table.html Basic table template (default). -django_tables2/bootstrap.html Template using bootstrap 3 structure/classes -django_tables2/bootstrap4.html Template using bootstrap 4 structure/classes -django_tables2/bootstrap-responsive.html Same as bootstrap, but wrapped in ``.table-responsive`` -django_tables2/semantic.html Template using semantic UI -======================================== ====================================================== +======================================== ====================================================== +Template name Description +======================================== ====================================================== +django_tables2/table.html Basic table template (default). +django_tables2/bootstrap.html Template using bootstrap 3 structure/classes +django_tables2/bootstrap-responsive.html Same as bootstrap, but wrapped in ``.table-responsive`` +django_tables2/bootstrap4.html Template using bootstrap 4 structure/classes +django_tables2/bootstrap4-responsive.html Same as bootstrap4, but wrapped in ``.table-responsive`` +django_tables2/bootstrap5.html Template using bootstrap 5 structure/classes +django_tables2/bootstrap5-responsive.html Same as bootstrap5, but wrapped in ``.table-responsive`` +django_tables2/semantic.html Template using semantic UI +======================================== ====================================================== By default, django-tables2 looks for the ``DJANGO_TABLES2_TEMPLATE`` setting which is ``django_tables2/table.html`` by default. -If you use bootstrap 3 for your site, it makes sense to set the default to -the bootstrap 3 template:: +If you use bootstrap 5 for your site, it makes sense to set the default to +the bootstrap 5 template:: - DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap.html" + DJANGO_TABLES2_TEMPLATE = "django_tables2/bootstrap5.html" If you want to specify a custom template for selected tables in your project, you can set a ``template_name`` attribute to your custom ``Table.Meta`` class::