Installation info of the django-ultratenant
PyPI name: django-ultratenant https://pypi.org/project/django-ultratenant/
Pythons >=3.7
Operating systems: Linux, Windows, OSX, Unix
Requirements: dj-database-url, django*
Installers: pip
Code repository: https://github.com/HBNetwork/django-ultratenant
Context of the origin of the library proposal
This library makes it possible to use tenant strategies in a django project.
In a multi-tenant architecture, multiple instances of an application share the environment. This architecture is able to work because each tenant is physically integrated but logically separate; which means that a single instance of the software will run on a server and then service multiple tenants (clients).
The dango ultratenant library that implements diferent approaches.
- multi-db
- multi-schema
- tenant-id
- Support multiple databases. Suported sqllite and postgresdb.
- Supported URL approaches: subdomain and path
- tenant.url.com
- url.com/tenant/admin/
-
In a django project implemented diferent approaches based of the bussiness core
-
Simple API with minimal setup
-
Transparent for the application
-
Supported isolations approaches (multi-db, multi-schema, tenant-id)
pip install django-ultratenant
In the settings.py file, install the app that corresponds to the chosen strategy:
...
INSTALLED_APPS=["test_project.singledb", "test_project.multidb"],
...
Put the information the created databases:
...
DATABASES={
"default": config("DATABASE_URL", default="sqlite://:memory:", cast=dburl),
"t1": config("DATABASE_URL", default="sqlite://:memory:", cast=dburl),
"t2": config("DATABASE_URL", default="sqlite://:memory:", cast=dburl),
},
...
...
# settings.py
from ultratenant.multidb import Databases
...
MIDDLEWARE = [
...
'ultratenant.path.Middleware',
]
...
DATABASES = Databases(config('DATABASE_URL', cast=dburl))
DATABASE_ROUTERS = ['ultratenant.multidb.Router']
...
set the urls depending on the chosen strategies
...
# urls.py
...
from ultimate_tenants.urls import tenants_path
urlpatterns = tenants_path([
path('admin/', admin.site.urls),
path('', index, name='index'),
])
# url.com/tenant/admin
...
HBNetwork
HBNetwork is a community of python programmers from Brazil established within the Dev Senior Passport.
-
Your contribution is welcome.
-
Setup your development environment and select issues.
git clone https://github.com/HBNetwork/django-ultratenant
cd django-ultratenant
git checkout main
Or
git clone git@github.com:HBNetwork/django-ultratenant.git
cd django-ultratenant
git checkout main
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install ".[test]"
pre-commit install
pre-commit autoupdate
pytest
git fetch origin
git checkout -b task/branch-name-you-work-issue
- https://github.com/django-tenants/django-tenants/ - only Postgres with multi-schema
- https://github.com/citusdata/django-multitenant - only Postgres (with Citus extension)
-
setup and pip
-
SQLite3 support
-
multi-db
-
tenant on URL path
-
documetation about how customize manage.py
-
other databases supported by Django: PostgreSQL, MariaDB, MySQL, Oracle
-
multi-schema
-
tenant-id
-
custom [manage.py]{.title-ref} to access different tenants
-
cookiecutter to create a new project
- First release on PyPI.