Skip to main content

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

dj-auto-multitenant-0.0.6.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

dj_auto_multitenant-0.0.6-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file dj-auto-multitenant-0.0.6.tar.gz.

File metadata

  • Download URL: dj-auto-multitenant-0.0.6.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for dj-auto-multitenant-0.0.6.tar.gz
Algorithm Hash digest
SHA256 07cb659ea60704729e0e2075ab600510107f0af702a3d78961d30a51aa01b16f
MD5 80710d65f4431f14d9ef3c1085a2df87
BLAKE2b-256 fbc5489298611135aa36a3c37132b85232351f66b2751f2ff4ea80ee72a4f7bd

See more details on using hashes here.

Provenance

File details

Details for the file dj_auto_multitenant-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: dj_auto_multitenant-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6

File hashes

Hashes for dj_auto_multitenant-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 012dc09f7f37e520e7a32baa3227027e91d46a5141eae2ebf40844386fed31f5
MD5 f8ef6444cbe8f45c326634206ce22f80
BLAKE2b-256 888fbdb3873fa53734e5f8cff5b0dcfdfc7a1f93d2cbf04488dc98d9369f64a0

See more details on using hashes here.

Provenance

Supported by

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