A small package to create tenants,schemas and domains only by providing a name.
Project description
customers
customers is a Django app which is used to serve django tenant details. It is used to create tenants, schemas and doamin urls for respective tenants. :fire:
Quick start
Install the package pip install dj-auto-multitenant
.
Now make change in your DATABASE_ENGINE
DATABASES = {
'default': {
'ENGINE': 'django_tenants.postgresql_backend',
# ..
}
}
Add DATABASE_ROUTERS setting, so that the correct apps can be synced, depending on what’s being synced (shared or tenant).
DATABASE_ROUTERS = (
'django_tenants.routers.TenantSyncRouter',
)
Add the middleware django_tenants.middleware.main.TenantMainMiddleware to the top of MIDDLEWARE, so that each request can be set to use the correct schema.
MIDDLEWARE = (
'django_tenants.middleware.main.TenantMainMiddleware',
#...
)
Now change your INSTALLED APPS settings and seprate your shared apps and tenant apps. Add your customers
app in SHARED APP.
SHARED_APPS = (
'django_tenants', # mandatory
'customers', # you must list the app where your tenant model resides in
'django.contrib.contenttypes',
# everything below here is optional
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
)
TENANT_APPS = (
# The following Django contrib apps must be in TENANT_APPS
'django.contrib.contenttypes',
# your tenant-specific apps
'myapp.houses',
)
INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]
Add: TENANT_MODEL = "customers.Client" # app.Model
TENANT_DOMAIN_MODEL = "customers.Domain" # app.Model
CLOUDAMQP = "<YOUR CLOUDAMQP URL>"
Now migrate customers python manage.py migrate_schemas --shared
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
Built Distribution
Hashes for dj-auto-multitenant-0.0.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba7c7100e055204b703a5a2ce311152d8db15e5889285772abcd2d26854b4fd9 |
|
MD5 | 4ec29580ea717a2a42dd3286a6cd0c79 |
|
BLAKE2b-256 | a30884c8b90564f13c76afbdfbd87af6e38a655680d45dee39c1ef5c39b0b399 |
Hashes for dj_auto_multitenant-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9865e6a4f0bc4fa995943c8291740f005b07ec1df1c4e3c8233a6125bf7d2d41 |
|
MD5 | bb274fe8421b5a7ddbbc85f82b19333a |
|
BLAKE2b-256 | ce646962fffeffc8bac0667f5f76b9bf76ed7a3b4e756480cbdd8fe6830ee73d |