semvec/pypi-packages huggingface dataset:
django-data-tables 0.4.3
Framework to create dynamic data table views in Django
License: MIT License

=====================
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