Skip to content

Commit

Permalink
Add bootstrap5-responsive.html template and update docs (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
mschoettle committed Mar 5, 2023
1 parent 52c1708 commit 2fa2f24
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
13 changes: 13 additions & 0 deletions django_tables2/templates/django_tables2/bootstrap5-responsive.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'django_tables2/bootstrap4.html' %}

{% block table-wrapper %}
<div class="table-container table-responsive">
{% block table %}
{{ block.super }}
{% endblock table %}

{% block pagination %}
{{ block.super }}
{% endblock pagination %}
</div>
{% endblock table-wrapper %}
27 changes: 15 additions & 12 deletions docs/pages/custom-rendering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down

0 comments on commit 2fa2f24

Please sign in to comment.