From f88ca61b34be876f26c2b99cb9f98baed3ad23f5 Mon Sep 17 00:00:00 2001
From: Pierre-antoine Comby <comby@crans.org>
Date: Tue, 13 Aug 2019 18:22:19 +0200
Subject: [PATCH] use django_tables2

---
 note_kfet/settings.py           |  4 +++-
 requirements.txt                |  1 +
 templates/member/club_list.html | 15 +++------------
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/note_kfet/settings.py b/note_kfet/settings.py
index 598e59ee..f64d1459 100644
--- a/note_kfet/settings.py
+++ b/note_kfet/settings.py
@@ -41,6 +41,7 @@ INSTALLED_APPS = [
     'guardian',
     'reversion',
     'crispy_forms',
+    'django_tables2',
     # Django contrib
     'django.contrib.admin',
     'django.contrib.admindocs',
@@ -83,6 +84,7 @@ TEMPLATES = [
                 'django.template.context_processors.request',
                 'django.contrib.auth.context_processors.auth',
                 'django.contrib.messages.context_processors.messages',
+                'django.template.context_processors.request',
             ],
         },
     },
@@ -159,7 +161,7 @@ STATICFILES_DIRS = [
     os.path.join(BASE_DIR,'static')]
 
 CRISPY_TEMPLATE_PACK = 'bootstrap4'
-
+DJANGO_TABLES2_TEMPLATE = 'django_tables2/bootstrap4.html'
 # URL prefix for static files.
 # Example: "http://example.com/static/", "http://static.example.com/"
 STATIC_URL = '/static/'
diff --git a/requirements.txt b/requirements.txt
index a5a9958b..d8aafa2d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -8,6 +8,7 @@ django-extensions==2.1.9
 django-guardian==1.4.9
 django-polymorphic==2.0.3
 django-reversion==3.0.3
+django-tables2==2.1.0
 docutils==0.14
 idna==2.8
 oauthlib==3.1.0
diff --git a/templates/member/club_list.html b/templates/member/club_list.html
index b4ddf6b9..dc1608f2 100644
--- a/templates/member/club_list.html
+++ b/templates/member/club_list.html
@@ -1,17 +1,8 @@
 {% extends "base.html" %}
+{% load render_table from django_tables2 %}
 {% block content %}
 
-<table class="table">
-<tr>
-    <td>ID</td>
-    <td>name</td>
-</tr>
-{% for object in object_list %}
-<tr>
-    <td>{{object.pk}}</td>
-    <td><a href="{{ object.get_absolute_url }}"> {{ object.name }}</a></td>
-</tr>
-{% endfor %}
-</table>
+{% render_table object_list %}
+
 <a class="btn btn-primary" href="{% url 'member:club_create' %}">New Club</a>
 {% endblock %}
-- 
GitLab