Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

Multitenant support for Django, using one tenant per database.

Project description

1. Install

$ pip install django-rds-db-multitenant

2. Implement a mapper

3. Update

Set the multitenant mapper by specifying the full dotted path to your implementation (in this example, mapper is the name of file

MULTITENANT_MAPPER_CLASS = 'myapp.mapper.TenantMapper'

Install the multitenant middleware as the first middleware of the list (prior to Django 1.10, you must use the MIDDLEWARE_CLASSES setting):


Change your database backend to the multitenant wrapper:

    'default': {
        'ENGINE': 'rds_db_multitenant.db.backends.mysql',
        'NAME': 'devnull',

Note: the NAME is useless for MySQL but due to a current limitation, the named database must exist. It may be empty and read-only.

Optionally, add the multitenant helper KEY_FUNCTION to your cache definition, which will cause cache keys to be prefixed with the value of mapper.get_cache_prefix:

  'default' : {
        'LOCATION': '',
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'KEY_FUNCTION': 'rds_db_multitenant.cache.helper.multitenant_key_func'

Project details

Release history Release notifications

This version
History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-rds-db-multitenant-0.3.3.tar.gz (6.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page