A django app which helps to implement multitenancy easily
Project description
## Django Multitenant ##
This app can be used to implement multitenant architecture within your django project very easily.
Inorder to install the app
```
pip install djangomultitenant
```
Modify the project settings file as shown below
```
DATABASES = {
'default': {
},
# DB for tenant 1
'akhil': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'akhil.sqlite3'),
},
# DB for tenant 2
'nikhil': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'nikhil.sqlite3'),
}
}
INSTALLED_APPS = [
'djangomultitenant',
]
DATABASE_ROUTERS = [
'djangomultitenant.Router',
]
MIDDLEWARE = [
'djangomultitenant.Middleware', # this has to be the first one
]
```
Use the TENANT-CODE header in all your requests to the django project. You can use [requestly](https://chrome.google.com/webstore/detail/requestly/mdnleldcmiljblolnjhpnblkcekpdkpa?hl=en) to send the headers while accessing project. In the production environment, these headers can be configured in the webservers.
```
TENANT-CODE: akhil
```
Tada !!! You are all equipped with multitenancy !!!
Note: migrations and management commands are not handled by this app. so please dont forget to use --database
This app can be used to implement multitenant architecture within your django project very easily.
Inorder to install the app
```
pip install djangomultitenant
```
Modify the project settings file as shown below
```
DATABASES = {
'default': {
},
# DB for tenant 1
'akhil': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'akhil.sqlite3'),
},
# DB for tenant 2
'nikhil': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'nikhil.sqlite3'),
}
}
INSTALLED_APPS = [
'djangomultitenant',
]
DATABASE_ROUTERS = [
'djangomultitenant.Router',
]
MIDDLEWARE = [
'djangomultitenant.Middleware', # this has to be the first one
]
```
Use the TENANT-CODE header in all your requests to the django project. You can use [requestly](https://chrome.google.com/webstore/detail/requestly/mdnleldcmiljblolnjhpnblkcekpdkpa?hl=en) to send the headers while accessing project. In the production environment, these headers can be configured in the webservers.
```
TENANT-CODE: akhil
```
Tada !!! You are all equipped with multitenancy !!!
Note: migrations and management commands are not handled by this app. so please dont forget to use --database
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file djangomultitenant-0.0.2.tar.gz
.
File metadata
- Download URL: djangomultitenant-0.0.2.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efaf409d7a7dd040d88b55adf08217a156c4437dcb7071b2e37143a147bee727 |
|
MD5 | 175f05ca7138f2a708760289a6ccb159 |
|
BLAKE2b-256 | 87d857be0aba0c7ab64c00b4edf55a71df8906b9e8504bef19af18305228e3b9 |