django-multiverse


Namedjango-multiverse JSON
Version 1.0.9 PyPI version JSON
download
home_pagehttps://github.com/dmp593/django-multiverse
SummaryDjango Multiverse: Multi-Tenancy for Django
upload_time2024-10-28 11:35:16
maintainerNone
docs_urlNone
authorDaniel Pinto
requires_python<4.0,>=3.10
licenseMIT
keywords django multiverse multi-tenancy tenants
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
pip install django-multiverse
```

Alternatively, you can add it to your `pyproject.toml` file:

```toml
[tool.poetry.dependencies]
django-multiverse = "^1.0.1"
```

## Usage

To use Django Multiverse in your project, follow these steps:

1. Add `multiverse` to your `INSTALLED_APPS` in `settings.py`:

    ```python
    INSTALLED_APPS = [
        ...
        'multiverse',
        ...
    ]
    ```

2. Configure your middleware to include `TenantMiddleware`:

    ```python
    MIDDLEWARE = [
        ...
        'django_multiverse.middleware.TenantMiddleware',
        ...
    ]
    ```

3. Define your tenant model and configure it in your settings:

    ```python
    TENANT_MODEL = 'yourapp.Tenant'
    ```

4. Separate the apps per system, tenant or common to both:

    ```python

    SYSTEM_APPS = [
        # ...
        'app0',
    ]

    COMMON_APPS = [
        # ...
        'app1',
        'app2',
    ]

    TENANT_APPS = [
        # ...
        'app3'
    ]

    INSTALLED_APPS = SYSTEM_APPS + COMMON_APPS + TENANT_APPS

    ``` 

5. Run the migrations

6. To create a tenant, use the management command:

    ```bash
    python manage.py create_tenant <subdomain> --database-name <database_name> --create-database --migrate
    ```

7. To destroy a tenant, use the management command:

    ```bash
    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](https://github.com/dmp593/django-multiverse).


### 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](https://www.buymeacoffee.com/dmp593).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dmp593/django-multiverse",
    "name": "django-multiverse",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "Django, Multiverse, Multi-Tenancy, Tenants",
    "author": "Daniel Pinto",
    "author_email": "dmp593@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3f/be/d6ee3e2f104aba71580b9f605d3cabdc5cce238dd2d2e6782f2481901a4a/django_multiverse-1.0.9.tar.gz",
    "platform": null,
    "description": "# Django Multiverse\n\nDjango 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).\n\n## Features\n\n- Easy integration with existing Django projects\n- Support for multiple Django versions (4.0, 4.1, 4.2, 5.0)\n- Compatible with Python 3.10, 3.11, and 3.12\n- Tenant separation in different databases\n- Middleware for tenant-aware requests\n- Utilities for tenant management\n- Support for Django Rest Framework (DRF) and Django Q2\n- MIT License\n\n## Installation\n\nTo install Django Multiverse, you can use pip:\n\n```bash\npip install django-multiverse\n```\n\nAlternatively, you can add it to your `pyproject.toml` file:\n\n```toml\n[tool.poetry.dependencies]\ndjango-multiverse = \"^1.0.1\"\n```\n\n## Usage\n\nTo use Django Multiverse in your project, follow these steps:\n\n1. Add `multiverse` to your `INSTALLED_APPS` in `settings.py`:\n\n    ```python\n    INSTALLED_APPS = [\n        ...\n        'multiverse',\n        ...\n    ]\n    ```\n\n2. Configure your middleware to include `TenantMiddleware`:\n\n    ```python\n    MIDDLEWARE = [\n        ...\n        'django_multiverse.middleware.TenantMiddleware',\n        ...\n    ]\n    ```\n\n3. Define your tenant model and configure it in your settings:\n\n    ```python\n    TENANT_MODEL = 'yourapp.Tenant'\n    ```\n\n4. Separate the apps per system, tenant or common to both:\n\n    ```python\n\n    SYSTEM_APPS = [\n        # ...\n        'app0',\n    ]\n\n    COMMON_APPS = [\n        # ...\n        'app1',\n        'app2',\n    ]\n\n    TENANT_APPS = [\n        # ...\n        'app3'\n    ]\n\n    INSTALLED_APPS = SYSTEM_APPS + COMMON_APPS + TENANT_APPS\n\n    ``` \n\n5. Run the migrations\n\n6. To create a tenant, use the management command:\n\n    ```bash\n    python manage.py create_tenant <subdomain> --database-name <database_name> --create-database --migrate\n    ```\n\n7. To destroy a tenant, use the management command:\n\n    ```bash\n    python manage.py destroy_tenant <lookup> --drop-database\n    ```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request or open an issue on our [GitHub repository](https://github.com/dmp593/django-multiverse).\n\n\n### Draft Mode\n\nAlthough 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.\n\n\n## License\n\nThis project is licensed under the MIT License.\n\n---\n\nThank you for reading!\n\nIf you like this library, you can support me by [buying me a coffee](https://www.buymeacoffee.com/dmp593).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django Multiverse: Multi-Tenancy for Django",
    "version": "1.0.9",
    "project_urls": {
        "Homepage": "https://github.com/dmp593/django-multiverse",
        "Repository": "https://github.com/dmp593/django-multiverse"
    },
    "split_keywords": [
        "django",
        " multiverse",
        " multi-tenancy",
        " tenants"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a71ddc656fc0523b658659f894701eb8be509ecef1099a406c6598eb195046c4",
                "md5": "1b1255856ab77ccc9da1747d972c1bdc",
                "sha256": "27b9cffda88291775f53bd10a7a9d937a1f6243336c32fd22c2240ffddc0d449"
            },
            "downloads": -1,
            "filename": "django_multiverse-1.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1b1255856ab77ccc9da1747d972c1bdc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 16940,
            "upload_time": "2024-10-28T11:35:15",
            "upload_time_iso_8601": "2024-10-28T11:35:15.485138Z",
            "url": "https://files.pythonhosted.org/packages/a7/1d/dc656fc0523b658659f894701eb8be509ecef1099a406c6598eb195046c4/django_multiverse-1.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3fbed6ee3e2f104aba71580b9f605d3cabdc5cce238dd2d2e6782f2481901a4a",
                "md5": "8d418d0783bd947b1dca52fad120c48b",
                "sha256": "a334e4afeffb08af0e5e703102704eec907084ba2b5578f9e248d24db9238184"
            },
            "downloads": -1,
            "filename": "django_multiverse-1.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "8d418d0783bd947b1dca52fad120c48b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 11787,
            "upload_time": "2024-10-28T11:35:16",
            "upload_time_iso_8601": "2024-10-28T11:35:16.759331Z",
            "url": "https://files.pythonhosted.org/packages/3f/be/d6ee3e2f104aba71580b9f605d3cabdc5cce238dd2d2e6782f2481901a4a/django_multiverse-1.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-28 11:35:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dmp593",
    "github_project": "django-multiverse",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-multiverse"
}
        
Elapsed time: 0.72381s