django dynamic datatb
v1.0.26
Django的Open-Source
库,以最小的努力提供powerful data table interface
(分页信息) - 由App-Generator积极支持。
要获得完整的功能集和长期支持,请查看Dynamic Django ,这是一个功能强大的入门工具,它包含:
特征
Django
和VanillaJS
DT
层Server-side
分页MIT License
(允许商业使用) 步骤#1 -
Install the package
$ pip install django-dynamic-datatb
// OR
$ pip install git+https://github.com/app-generator/django-dynamic-datatb.git
步骤#2 - 更新配置,
add new imports
import os , inspect
import django_dyn_dt
步骤#3 - 更新配置,
include the new APPs
INSTALLED_APPS = [
'django_dyn_dt' , # <-- NEW App
]
步骤 #4 - 更新配置,包括新的
TEMPLATES
DIR
TEMPLATE_DIR_DATATB = os . path . join ( BASE_DIR , "django_dyn_dt/templates" ) # <-- NEW App
TEMPLATES = [
{
"BACKEND" : "django.template.backends.django.DjangoTemplates" ,
"DIRS" : [ TEMPLATE_DIR_DATATB ], # <-- NEW Include
"APP_DIRS" : True ,
"OPTIONS" : {
},
},
]
步骤#5 - 更新配置,更新
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" ),
)
步骤#6 - 在
settings.py
中Register the model
(DYNAMIC_DATATB 部分)
此示例代码假设app1
存在并且模型Book
已定义并迁移。
DYNAMIC_DATATB = {
# SLUG -> Import_PATH
'books' : "app1.models.Book" ,
}
步骤#7 -
Update routing
,包括 API
from django . contrib import admin
from django . urls import path , include # <-- NEW: 'include` directive added
urlpatterns = [
path ( "admin/" , admin . site . urls ),
path ( '' , include ( 'django_dyn_dt.urls' )), # <-- NEW: API routing rules
]
步骤#8 - 使用动态数据表模块
如果托管模型是Books
,则动态接口是/datatb/books/
并且所有功能都可用。
AppSeed
提供的更多开发者工具Email
和Discord
寻求支持Django Dynamic DataTables - App-Generator提供的开源库