Django Multiverse: Multi-Tenancy for Django
Project description
Django Multiverse
Django Multiverse: A Multi-Tenancy reusable Django app that provides a robust and flexible way to manage tenants in your Django project. This package is distinguished from the popular django-tenants because it separates the tenants into different databases. (Currently supports SQLite and PostgreSQL).
Features
- Easy integration with existing Django projects
- Support for multiple Django versions (4.0, 4.1, 4.2, 5.0)
- Compatible with Python 3.10, 3.11, and 3.12
- Tenant separation in different databases
- Middleware for tenant-aware requests
- Utilities for tenant management
- Support for Django Rest Framework (DRF) and Django Q2
- MIT License
Installation
To install Django Multiverse, you can use pip:
pip install django-multiverse
Alternatively, you can add it to your pyproject.toml
file:
[tool.poetry.dependencies]
django-multiverse = "^1.0.6"
Usage
To use Django Multiverse in your project, follow these steps:
-
Add
multiverse
to yourINSTALLED_APPS
insettings.py
:INSTALLED_APPS = [ ... 'multiverse', ... ]
-
Configure your middleware to include
TenantMiddleware
:MIDDLEWARE = [ ... 'django_multiverse.middleware.TenantMiddleware', ... ]
-
Define your tenant model and configure it in your settings:
TENANT_MODEL = 'yourapp.Tenant'
-
Use the provided mixins and decorators to manage tenant-specific views and models.
-
To create a tenant, use the management command:
python manage.py create_tenant <subdomain> --database-name <database_name> --create-database --migrate
-
To destroy a tenant, use the management command:
python manage.py destroy_tenant <lookup> --drop-database
Contributing
Contributions are welcome! Please feel free to submit a Pull Request or open an issue on our GitHub repository.
Draft Mode
Although this library is being used in production in some of my projects, this documentation is currently a draft. If you are interested in exploring further, you are welcome to open a pull request with your questions, and I will gladly assist you if I can.
License
This project is licensed under the MIT License.
Thank you for reading!
If you like this library, you can support me by buying me a coffee.
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
Built Distribution
Hashes for django_multiverse-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd4f60ea1162bc8544f279bb2e057063c560a0a77527c5c698e25e44bd4cedc4 |
|
MD5 | a1085e00cc37e9191598333e1eeff0b6 |
|
BLAKE2b-256 | c495695fecbcb1be95469a81dcaa91a5299482f1e32a8a2ba7049538e3a7b1d3 |