Django Data Tables 0.4.3 | Coderz Repository

django-data-tables 0.4.3

Last updated:

0 purchases

django-data-tables 0.4.3 Image
django-data-tables 0.4.3 Images

Free

Languages

Categories

Add to Cart

Description:

djangodatatables 0.4.3

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

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product: (if this is empty don't purchase this product)

Customer Reviews

There are no reviews.