diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 4335bf2..37a0a84 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,16 @@
CHANGELOG
===========
+v. 2.2.0
+--------
+
+ * Add new classes:
+ * ``ColumnShiftTableBootstrap4Responsive`` - only for django-tables2 >= 2.5.0
+ * ``ColumnShiftTableBootstrap5Responsive`` - only for django-tables2 >= 2.5.3
+
+ Classes able to use responsive tables with Bootstrap v4 and v5
+ Author: @mpibpc-mroose
+
v. 2.1.1
--------
diff --git a/README.rst b/README.rst
index 7efe571..d1bbff4 100644
--- a/README.rst
+++ b/README.rst
@@ -33,8 +33,10 @@ Using JQuery, Bootstrap3 or Bootstrap4 or Bootstrap5 and Django >=1.9.
* for bootstrap2 - ColumnShiftTableBootstrap2,
* for bootstrap3 - ColumnShiftTableBootstrap3,
- * for bootstrap4 - ColumnShiftTableBootstrap4,
- * for bootstrap5 - ColumnShiftTableBootstrap5,
+ * for bootstrap4 - ColumnShiftTableBootstrap4
+ * for bootstrap4 in responsive mode - ColumnShiftTableBootstrap4Responsive (only for django-tables2 >= 2.5)
+ * for bootstrap5 - ColumnShiftTableBootstrap5
+ * for bootstrap5 in responsive mode - ColumnShiftTableBootstrap5Responsive (only for django-tables2 >= 2.5.3)
**Tested by tox with:**
@@ -218,11 +220,16 @@ Bootstrap4 :
If you use Bootstrap v4 in your project then table class has to inherit from `ColumnShiftTableBootstrap4`
imported from `django_tables2_column_shifter.tables`.
+Alternatively if you want to use `table-responsive` your table class has to inherit from
+ColumnShiftTableBootstrap4Responsive (only for django-tables2 >= 2.5).
+
Bootstrap5:
--------------------------------------
If you use Bootstrap v5 in your project then table class has to inherit from `ColumnShiftTableBootstrap5`
imported from `django_tables2_column_shifter.tables`.
+Alternatively if you want to use `table-responsive` your table class has to inherit from
+ColumnShiftTableBootstrap5Responsive (only for django-tables2 >= 2.5.3).
Warnings:
diff --git a/django_tables2_column_shifter/__init__.py b/django_tables2_column_shifter/__init__.py
index c878191..243016b 100644
--- a/django_tables2_column_shifter/__init__.py
+++ b/django_tables2_column_shifter/__init__.py
@@ -1,2 +1,2 @@
-VERSION = (2, 1, 1)
+VERSION = (2, 2, 0)
__version__ = ".".join(str(i) for i in VERSION)
diff --git a/django_tables2_column_shifter/tables.py b/django_tables2_column_shifter/tables.py
index b21ec86..20f3180 100644
--- a/django_tables2_column_shifter/tables.py
+++ b/django_tables2_column_shifter/tables.py
@@ -1,8 +1,9 @@
import django_tables2 as tables
+dt_version = tuple(map(int, tables.__version__.split(".")[:3]))
-class ColumnShiftTable(tables.Table):
+class ColumnShiftTable(tables.Table):
# If button for shifting columns is visible
shift_table_column = True
@@ -89,9 +90,47 @@ class ColumnShiftTableBootstrap4(ColumnShiftTable):
shifter_template = "django_tables2_column_shifter/bootstrap4.html"
+class ColumnShiftTableBootstrap4Responsive(ColumnShiftTable):
+ """
+ Table class compatible with Bootstrap 4 and using "table-responsive" css class.
+ """
+ shifter_template = "django_tables2_column_shifter/bootstrap4-responsive.html"
+
+ def __init__(self, *args, **kwargs):
+ if dt_version < (2, 5):
+ raise AssertionError(
+ "ColumnShiftTableBootstrap4Responsive require django-tables2 >= 2.5 "
+ "your current version is {}".format(tables.__version__)
+ )
+ super(ColumnShiftTableBootstrap4Responsive, self).__init__(*args, **kwargs)
+
+
class ColumnShiftTableBootstrap5(ColumnShiftTable):
"""
Table class compatible with bootstrap 5
"""
dropdown_button_css = "btn btn-light btn-sm"
shifter_template = "django_tables2_column_shifter/bootstrap5.html"
+
+ def __init__(self, *args, **kwargs):
+ if dt_version < (2, 5):
+ raise AssertionError(
+ "ColumnShiftTableBootstrap5 require django-tables2 >= 2.5 "
+ "your current version is {}".format(tables.__version__)
+ )
+ super(ColumnShiftTableBootstrap5, self).__init__(*args, **kwargs)
+
+
+class ColumnShiftTableBootstrap5Responsive(ColumnShiftTableBootstrap5):
+ """
+ Table class compatible with Bootstrap 5 and using "table-responsive" css class.
+ """
+ shifter_template = "django_tables2_column_shifter/bootstrap5-responsive.html"
+
+ def __init__(self, *args, **kwargs):
+ if dt_version < (2, 5, 3):
+ raise AssertionError(
+ "ColumnShiftTableBootstrap5Responsive require django-tables2 >= 2.5.3 "
+ "your current version is {}".format(tables.__version__)
+ )
+ super(ColumnShiftTableBootstrap5Responsive, self).__init__(*args, **kwargs)
diff --git a/django_tables2_column_shifter/templates/django_tables2_column_shifter/_partials/bootstrap4_table_block.html b/django_tables2_column_shifter/templates/django_tables2_column_shifter/_partials/bootstrap4_table_block.html
new file mode 100644
index 0000000..2f6e502
--- /dev/null
+++ b/django_tables2_column_shifter/templates/django_tables2_column_shifter/_partials/bootstrap4_table_block.html
@@ -0,0 +1,80 @@
+{% load trans from i18n %}
+{% load static %}
+
+
+
+
+
+
+
+
+ {% for column in table.columns %}
+ {% if column.attrs.td.class not in table.get_column_excluded %}
+ {% if column.attrs.td.class in table.get_column_default_show %}
+
+
+
+ {{ column.header }}
+
+ {% else %}
+
+
+
+ {{ column.header }}
+
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+
+
{# End btn-group#}
+
+ {# Loader default is show #}
+
+
+ {% trans "Table content is loading..."%}
+
{# End loader #}
+
diff --git a/django_tables2_column_shifter/templates/django_tables2_column_shifter/_partials/bootstrap5_table_block.html b/django_tables2_column_shifter/templates/django_tables2_column_shifter/_partials/bootstrap5_table_block.html
new file mode 100644
index 0000000..47a3f7c
--- /dev/null
+++ b/django_tables2_column_shifter/templates/django_tables2_column_shifter/_partials/bootstrap5_table_block.html
@@ -0,0 +1,79 @@
+{% load trans from i18n %}
+{% load static %}
+
+
+
+
+ {% for column in table.columns %}
+ {% if column.attrs.td.class not in table.get_column_excluded %}
+ {% if column.attrs.td.class in table.get_column_default_show %}
+
+
+
+ {{ column.header }}
+
+ {% else %}
+
+
+
+ {{ column.header }}
+
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+
+
{# End btn-group#}
+
+ {# Loader default is show #}
+
+
+ {% trans "Table content is loading..."%}
+
{# End loader #}
diff --git a/django_tables2_column_shifter/templates/django_tables2_column_shifter/bootstrap4-responsive.html b/django_tables2_column_shifter/templates/django_tables2_column_shifter/bootstrap4-responsive.html
new file mode 100644
index 0000000..6b620d3
--- /dev/null
+++ b/django_tables2_column_shifter/templates/django_tables2_column_shifter/bootstrap4-responsive.html
@@ -0,0 +1,17 @@
+{% extends "django_tables2/bootstrap4-responsive.html" %}
+
+{% block table %}
+{% if table.shift_table_column %}
+
+ {% include 'django_tables2_column_shifter/_partials/bootstrap4_table_block.html' %}
+
+ {# Wrapper default is hide #}
+
+ {% include 'django_tables2_column_shifter/_partials/bootstrap4_table_block.html' %}
-
-
-
- {% for column in table.columns %}
- {% if column.attrs.td.class not in table.get_column_excluded %}
- {% if column.attrs.td.class in table.get_column_default_show %}
-
-
-
- {{ column.header }}
-
- {% else %}
-
-
-
- {{ column.header }}
-
- {% endif %}
- {% endif %}
- {% endfor %}
-
-
{# End btn-group#}
-
- {# Loader default is show #}
-
-
- {% trans "Table content is loading..."%}
-
{# End loader #}
-
- {# Wrapper degault is hide #}
+ {# Wrapper default is hide #}
+ {% include 'django_tables2_column_shifter/_partials/bootstrap5_table_block.html' %}
-
-
-
- {% for column in table.columns %}
- {% if column.attrs.td.class not in table.get_column_excluded %}
- {% if column.attrs.td.class in table.get_column_default_show %}
-
-
-
- {{ column.header }}
-
- {% else %}
-
-
-
- {{ column.header }}
-
- {% endif %}
- {% endif %}
- {% endfor %}
-
-
{# End btn-group#}
-
- {# Loader default is show #}
-
-
- {% trans "Table content is loading..."%}
-
{# End loader #}
-
- {# Wrapper degault is hide #}
+ {# Wrapper default is hide #}