Skip to main content

Django Data Tables

Django Data Tables is a Framework for Django that creates model related Data Tables that fetch filtered data via AJAX Requests and allow different actions on model instances.

This is a reimplementation of a libary that was developed and heavily used in a big inhouse enterprise software at Studitemps GmbH. This implemetation is still in a very early stage of development. You can play around but expect a few breaking changes before reaching version 1.0.0.

Detailed documentation is still missinig but will be added hopefully soon.

Quick start

1. Add “django_data_tables” to your INSTALLED_APPS in your settings.py like this:

INSTALLED_APPS = [
    ...
    'django_data_tables',
    ...
]

2. Include the autodiscover and URLconf in your project urls.py like this:

from django_data_tables.utils import autodiscover as ddt_autodiscover
from django_data_tables import views as dt_views

ddt_autodiscover()

...
path('ddt/get_data/<table_name>/', dt_views.get_data, name='ddt-get_data'),
path('ddt/action/<table_name>', dt_views.action, name='ddt-action'),
...

3. Create a tables.py in an app where you want to create a data table with something like this:

import django_data_tables as ddt

from .forms import MyEditForm

class EditAction(ddt.FormAction):
     name = 'Edit'
     form_class = MyEditForm

     def success(self, form, obj):
         form.save()


class BaseDataTable(ddt.DataTable):
     columns = [
        ddt.IdColumn('id'),
        ddt.ModelFieldColumn('<some existing field e.g. "name">',
        ddt.ActionColumn('Do')
     ]
     filters = {'id_filter': ddt.IntFilter('id'),}
     actions = [EditAction,]
     model = '<your_app_name>.<YourModel>'

4. In your view create a table renderer instance and pass it into the renderers context. So in your apps views do something like that:

from .tables import BaseDataTable

...

def my_fancy_view(request):
    table = BaseDataTable().get_renderer(request)
    return render(request, 'app/my_views_template.html', {'table': table})

5. In my_views_template.html render the table (very similar to django forms:

<html>
    <head>
    {{ table.media }}
    </head>
    <body>
        <h1>Example for a Django Data Table Renderer</h1>
        {{ table }}
    </body>
</html>

6. Create a route to your view in urls as usual an test it

Metadata

Release files for django-data-tables 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-data-tables 0.4.3
File Size Uploaded
django_data_tables-0.4.3.tar.gz 17.6 kB Details

Release files / django_data_tables-0.4.3.tar.gz

Download URL django_data_tables-0.4.3.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3d7dca72fda9dc426af5c91425ca2a358442c085bfb31070b6679a6e4522f617
BLAKE2b-256 checksum
How to use checksums
e095249fbbc302a4c84b4576132c29c18bcbd09976a19e8b35e3f2b8db704f9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.8.1

Release history Release notifications | RSS feed

This release

0.4.3 This release

1 release file

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page