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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a85532b74425b526ecb694d104101249772fd82db3ddff641b23e5e95eafea3 |
|
MD5 | b43cce24e7b940b11229e7b56c0badcb |
|
BLAKE2b-256 | 65cd373180e9adc0cb2213361585635d5b2927c71277351d348c1e39e7f799ed |
Hashes for dj_auto_multitenant-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45554a8f6ba6ada0f582fda1ddb110a7b97f10ea36fc3e52466ff351edc7bce7 |
|
MD5 | ea62690d4b52b158888f374edf8444b6 |
|
BLAKE2b-256 | 69183d01efa409f751cc5c1017e5e2b436b44f3d43acfb27a034b78d1a2de0c1 |