Releases: adamghill/dj-lite-tenant
Releases · adamghill/dj-lite-tenant
0.2.0
0.1.0
0.1.0
Forked from django-sqlite-user-db by MessyComposer.
Architecture Changes
- Switched from
asgiref.local.Localtocontextvars.ContextVar - Replaced per-model
_is_user_modelflags with settings-driven routing viaDJ_LITE_TENANT["APPS"] - Changed DB alias detection from naming convention to path-based
- Added
slugify()sanitization for tenant PKs in filenames - Custom
dj_lite_tenant.backends.sqlite3backend wired throughdj-lite'ssqlite_config - Template-based DB provisioning is now opt-in (
USE_DATABASE_TEMPLATE=True); default is directmigrate
New Features
- Cross-database
ATTACH DATABASE— runs automatically on tenant connections for SQL joins - ORM dot-schema support — custom backend enables
Meta.db_table = "catalog.tablename" ATTACHMENTS— configurable dict of named databases to attach to every tenant connectionDB_NAME_PATTERN— configurable filename pattern for tenant DB filesTENANT_MODEL— custom tenant model support (defaults to Django's auth user model)TENANT_ID_CALLABLE— pluggable callable for extracting the tenant PK from a requestTENANT_SETTINGS— configurable per-tenant DB connection options- LRU connection registry with
MAX_OPEN_CONNECTIONSeviction per worker - Auto-create tenant DB on first request; auto-delete on model delete (
DELETE_TENANT_DB_ON_DELETE) post_migratesignal clears template cache when tenant app migrations are appliedtenant_db()context manager for out-of-request use (management commands, async tasks)SwitchTenantAdminmixin — adds Switch/Reset buttons in the Django admin list viewset_tenant/unset_tenantviews + URL patterns for superuser tenant impersonationcreate_tenant_db <pk>management command — creates and migrates a specific tenant DBmigrate_tenant_dbsmanagement command — applies migrations to all existing tenant DBs