A Django library to enable semi-isolated multitenancy in your project with users outside the tenant.
Project description
Configuración de Django Multitenant
- Instalación de Django y creación de proyecto y app.
pip install django
django-admin startproject myproject
python manage.py startapp baseapp
cd myproject
- Instalación de django-tenantflow.
pip install django-tenantflow
- Configuración de la aplicación.
INSTALLED_APPS = [
...
'tenantflow',
'baseapp',
...
]
- Agregar el middleware de tenantflow.
MIDDLEWARE = [
...
'tenantflow.middleware.TenantMiddleware',
...
]
- Configuraciones de la librerÃa.
TENANTFLOW_DEFAULT_SCHEMA = 'public' # Esquema predeterminado
TENANTFLOW_VALIDATION = True # Habilitar validación de acceso al tenant
TENANTFLOW_SWITCH_METHOD = 'session' # Métodos disponibles: session, subdomain, header
TENANTFLOW_ACCOUNT_MODEL = "baseapp.Account" # Modelo de cuenta
- Crear modelos para cuentas y usuarios.
from tenantflow.models import AbstractAccount, AbstractUserAccount
class Account(AbstractAccount):
pass
class UserAccount(AbstractUserAccount):
account = models.ForeignKey(Account, on_delete=models.CASCADE)
- Aplicar migraciones al esquema público.
python manage.py makemigrations
python manage.py migrate
- Para crear un tenant, se puede hacer con los comandos entregados por la librerÃa.
python manage.py create_tenant schemaname "Tenant Name
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_tenantflow-1.0.11.tar.gz.
File metadata
- Download URL: django_tenantflow-1.0.11.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8daeef089565287085a2cad33f2d5ac8c6f7095bf9b5a995627c31e22eee686
|
|
| MD5 |
add0a42543e9161f0f07c5125670fe6a
|
|
| BLAKE2b-256 |
83d2d2df73c4d79a681595c359c296fc23e5b4894db6d35e9aa02ca1af373a16
|
File details
Details for the file django_tenantflow-1.0.11-py3-none-any.whl.
File metadata
- Download URL: django_tenantflow-1.0.11-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab313d15ddbcd027419d30a50add6e74934aa57e4a6c5a6075d5faad75de7a86
|
|
| MD5 |
dc7b8b34ee5df7d3191f576af3265ffb
|
|
| BLAKE2b-256 |
c1627cc4365c0d0685143800179ce719c1e2021d7753eee9e207b96932fde70c
|