-
clone the repository :
git clone https://github.com/Puja0708/multi-tenant-system.git
-
make virtual environment (optional):
virtualenv -p python3 venv
-
activate virtual environment and install dependencies
source venv/bin/activate pip install -p requirements/<dev/staging/prod>.pip
-
Run Migrations
./manage.py migrate_schemas --shared --settings=multi_tenant_system.settings.<dev/staging/prod>
-
Create superuser
./manage.py createsuperuser --settings=multi_tenant_system.settings.<dev/staging/prod>
-
Login to django admin console to create tenants (You can also do it using django shell. It is exactly like creating any django model object and saving it).
-
Create Employee Roles and Teams (using shell or their corresponding APIs/ Forms.
-
Create Employee (
/employees
)
Now you can play around with this. In this project, companies.models.Company
is the main tenant model.
You can create tenants from the django admin console.
- Running test cases :
./manage.py test employees.tests --settings=multi_tenant_system.settings.dev
fc7a5c24747754e98cbfd4fb7b8a24e2cafade12 - make an entry in the
/etc/hosts/
file mapping your localhost to a fake domain. eg :127.0.0.1 example.com tenant1.example.com tenant2.example.com
.
TODO : - auth for companies, employees etc (use DRF authentication_classes and permission_classes.) - api tests