django-tenanet
Tenanet is a simple multi-tenancy framework for Django. It features a simple tenant data model, a middleware to handle tenant resolution, a context processor and a query manager to handle tenant data isolation.
Works well with django-allauth or other custom User models. TenantUser association is inlined in the default User admin form and the default User serializer.
A swappable Tenant metaclass is provided to allow for custom metadata (e.g. app-specific preferences, filters, feature flags, etc.) to be added to the Tenants.
Features
- Tenant data model
- Tenant middleware
- Tenant query manager
- Swappable Tenant metaclass
Requirements (tested)
- Python 3.6+
- Django 4.0+
Installation
pip install django-tenanet
Usage
Settings
Add tenanet to your INSTALLED_APPS:
INSTALLED_APPS = (
...
'tenanet',
)
Add tenanet.middleware.TenantMiddleware to your MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES = (
...
'tenanet.middleware.TenantMiddleware',
)
Override the TENANET_TENANT_MODEL setting to point to your custom tenant model:
TENANET_TENANT_MODEL = 'myapp.MyTenantModel'
Models
TenantMeta
from tenanet.models import BaseTenantMeta
class MyTenantMeta(BaseTenantMeta):
# Add custom tenant metadata fields here
Tenant scoped data with TenantDataModel
from tenanet.models import TenantDataModel
class MyTenantModel(TenantDataModel):
# Add custom tenant data model fields here
Admin
TenantUser inline
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from tenanet.admin import TenantUserAssociationInline
class MyUserAdmin(UserAdmin):
# your user admin config here
inlines = (TenantUserAssociationInline,)
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
License
This project is licensed under the terms of the Django-Tenanet Limited Use License. See the LICENSE file for license rights and limitations.
Metadata
Release files for django-tenanet 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-tenanet-0.1.1.tar.gz | 9.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_tenanet-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.3 kB
Release files / django-tenanet-0.1.1.tar.gz
| Download URL | django-tenanet-0.1.1.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35606bd11a8589e4bdb7f7514bbb71a5d578047d944484428f739b3db9bdacdc
|
|
BLAKE2b-256 checksum How to use checksums |
3a2a63eec920e62ecdab14bd41bf05ad25682334d319b5605c0a8484b37879c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / django_tenanet-0.1.1-py3-none-any.whl
| Download URL | django_tenanet-0.1.1-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f8f4597051d929f8b334259303079c0fbabcda3ab2cb61d9f2bb42d0e85dde9
|
|
BLAKE2b-256 checksum How to use checksums |
a5af3943eb0a3217b60071a37ae5ed52ff994904350418f983e9a2f1c999bb6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|