Skip to main content

A Django library to enable semi-isolated multitenancy in your project with users outside the tenant.

Project description

Configuración de Django Multitenant

  1. 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
  1. Instalación de django-tenantflow.
pip install django-tenantflow
  1. Configuración de la aplicación.
INSTALLED_APPS = [
    ...
    'tenantflow',
    'baseapp',
    ...
]
  1. Agregar el middleware de tenantflow.
MIDDLEWARE = [
    ...
    'tenantflow.middleware.TenantMiddleware',
    ...
]
  1. 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
  1. 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)
  1. Aplicar migraciones al esquema público.
python manage.py makemigrations
python manage.py migrate
  1. 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


Download files

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

Source Distribution

django_tenantflow-1.0.10.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_tenantflow-1.0.10-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file django_tenantflow-1.0.10.tar.gz.

File metadata

  • Download URL: django_tenantflow-1.0.10.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

Hashes for django_tenantflow-1.0.10.tar.gz
Algorithm Hash digest
SHA256 cc6a93cd6ae4a42fc3134d08d741b4c3070c543df204536a47001bf08bc45305
MD5 695d34a1b01bc87857df946a1414c277
BLAKE2b-256 82f940fd1585555ca1da5dcf2ba1706a2c63e1dab5b632d3f2828576746b8702

See more details on using hashes here.

File details

Details for the file django_tenantflow-1.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tenantflow-1.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 fa1a8ea195e0d8d586c2bff711af4e5be4be4fc223fc18a5f0c2a2ee976b5dd1
MD5 796e39f75ad4ecfebd36cf235c9f6824
BLAKE2b-256 75842128b6ccfa64cce90b854596df2fb8d9308819bfecbe9e49a91a7b011415

See more details on using hashes here.

Supported by

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