Skip to main content

Django Dynamic Datatables

Project description

Django Dynamic DataTables

Open-Source library for Django that provides a powerful data table interface (paginated information) with minimum effort - actively supported by AppSeed.


Features

  • Modern Stack: Django & VanillaJS
  • DT layer provided by Simple-DataTables
  • Server-side pagination
  • Search, Filters
  • Exports in PDF, CSV formats
  • MIT License (commercial use allowed)

Django Dynamic DataTables - Open-Source tool provided by AppSeed.


How to use it


Step #1 - Install the package

$ pip install django-dynamic-datatb
// OR
$ pip install git+https://github.com/app-generator/django-dynamic-datatb.git

Step #2 - Update Configuration, add new imports

import os, inspect
import django_dyn_dt

Step #3 - Update Configuration, include the new APPs

INSTALLED_APPS = [
    'django_dyn_dt',  # <-- NEW App
]

Step #4 - Update Configuration, include the new TEMPLATES DIR

DATATB_TEMPLATES = os.path.join(BASE_DIR, "django_dyn_dt/templates")   # <-- NEW Templates Include

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [DATATB_TEMPLATES],                                    # <-- NEW Include
        "APP_DIRS": True,
        "OPTIONS": {
        },
    },
]

Step #5 - Update Configuration, update STATICFILES_DIRS DIR

DYN_DB_PKG_ROOT = os.path.dirname( inspect.getfile( django_dyn_dt ) ) # <-- NEW App

STATICFILES_DIRS = (
    os.path.join(DYN_DB_PKG_ROOT, "templates/static"),
)

Step #6 - Update routing, include APIs

from django.contrib import admin
from django.urls import path, include                 # <-- NEW: 'include` directive added
from django.views.decorators.csrf import csrf_exempt  # <-- NEW: csrf_exempt required 

urlpatterns = [
    path("admin/", admin.site.urls),

    path('datatb/<str:model_name>/<int:pk>/', csrf_exempt(DataTB.as_view())),  # <-- NEW: (Used by Dynamic DataTables)
    path('datatb/<str:model_name>/'         , csrf_exempt(DataTB.as_view())),  # <-- NEW: (Used by Dynamic DataTables)
    path('datatb/<str:model_name>/export/'  , csrf_exempt(export)),            # <-- NEW: (Used by Dynamic DataTables)

]    

Step #7 - Use the Dynamic Datatable widget in controller

from django_dyn_dt.datatb import DataTB

def dyn_datatb(request):

    context = {} 
        
    ddt = DataTB(model_class_path="home.models.Product")  # Link Dynamic view to a Model (full path)
    context['data_table1'] = ddt.render()                 # Render() returns the dynamic widget

    return render(request, 'pages/dyn-datatb.html', context=context)

Django Dynamic DataTables - Open-Source Tool for Developers.


Links & resources



Django Dynamic DataTables - Open-source library provided by AppSeed

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-dynamic-datatb-1.0.22.tar.gz (33.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page