AdminLTE PRO DataTables#
This page explains how the Dynamic DataTables feature of Django AdminLTE PRO can be used to manage any DB table using a powerful paginated view:
👉 Django Dynamic DataTables - LIVE Demo
👉 New to App-Generator? Sign IN with GitHub or Generate Web Apps in no time (free service).
Configuration#
Dynamic DataTable section provides a simple way to specify the models that are automatically managed.
The section is a dictionary where the key is the segment of the endpoint and the value the import path of the model. Here are the DEMOs for the default models:
# Syntax: Complete import path for Model & Form
DYNAMIC_DATATB = {
# Model -> Form
'apps.common.models.Sales' : "apps.common.forms.SalesForm",
'apps.common.models.Products' : "apps.common.forms.ProductsForm",
}
Add a new Model#
Besides the default tables view (Sales and Product models), the Dynamic DataTable feature can be extended to any new model. Here are the steps to enable a new endpoint
Define a new model Homework in the common aplication
class Homework(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=100)
content = models.TextField(blank=True, null=True, default='')
Migrate the database
python manage.py makemigrations
python manage.py migrate
Define a form for the new model
class HomeworkForm(forms.ModelForm):
class Meta:
model = Homework
fields = '__all__'
Update the configuration: DYNAMIC_API section
# Syntax: Complete import path for Model & Form
DYNAMIC_DATATB = {
# Model -> Form
'apps.common.models.Sales' : "apps.common.forms.SalesForm",
'apps.common.models.Products' : "apps.common.forms.ProductsForm",
'apps.common.models.Titanic' : "apps.common.forms.TitanicForm", # <-- NEW
}
The new view is now listed in the Dynamic DataTable page and ready to be used.
Links#
👉 New to App-Generator? Join our 10k+ Community using GitHub One-Click SignIN.
👉
Download
products and start fast a new project👉 Bootstrap your startUp, MVP or Legacy project with a custom development sprint