This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
python-entrouvert/entrouvert/djommon/multitenant
Serghei Mihai 1d6a010895 readme updated 2014-04-23 09:50:35 +02:00
..
management multitenenant extension 2014-02-04 15:14:44 +01:00
README readme updated 2014-04-23 09:50:35 +02:00
__init__.py multitenenant extension 2014-02-04 15:14:44 +01:00
app_settings.py multitenenant extension 2014-02-04 15:14:44 +01:00
middleware.py multitenenant extension 2014-02-04 15:14:44 +01:00
models.py multitenant: little fixes in models.py 2014-03-16 16:47:09 +01:00
template_loader.py multitenenant extension 2014-02-04 15:14:44 +01:00
tests.py multitenenant extension 2014-02-04 15:14:44 +01:00
views.py multitenenant extension 2014-02-04 15:14:44 +01:00

README

Multitenant
-----------

An application for making a Django application multitenant for Entr'ouvert
customers.

Install
-------

Set the tenant model:

    TENANT_MODEL = 'multitenant.Tenant'

Add the middlewares for multitenant, they must be first:

    MIDDLEWARE_CLASSES = (
        'tenant_schemas.middleware.TenantMiddleware',
        'entrouvert.djommon.multitenant.middleware.EOTenantMiddleware',
        ...
    )

Add the multitenant filesystem template loader:

    TEMPLATE_LOADERS = (
       'entrouvert.djommon.multitenant.template_loader.FilesystemLoader'
       ....
    )

Configure where the multitenant templates are located:


    MULTITENANT_TEMPLATE_DIRS = ('/var/lib/my_project/templates/',)

Define the shared application:


    SHARED_APPS = (
        'tenant_schemas',
        'entrouvert.djommon.multitenant',
        # those are needed for the public apps to work
        # add also any application needed by the public app
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.sites',
    )

    TENANT_APPS = INSTALLED_APPS

    INSTALLED_APPS += ('tenant_schemas', 'entrouvert.djommon.multitenant')

Use multitenant database engine:

    DATABASES = {
        'default': {
            'ENGINE': 'tenant_schemas.postgresql_backend',
            'NAME': '<db_name>',
        },
    }

Use multitenant south adapter:

    SOUTH_DATABASE_ADAPTERS = {
        'default': 'south.db.postgresql_psycopg2',
    }