Skip to main content

Django router for apps with more than 1 database

Project description

https://img.shields.io/pypi/v/django-database-for-apps.svg https://travis-ci.org/dex4er/django-database-for-apps.svg?branch=master https://readthedocs.org/projects/django-database-for-apps/badge/?version=latest https://img.shields.io/pypi/pyversions/django-database-for-apps.svg https://img.shields.io/pypi/djversions/django-database-for-apps.svg

django-database-for-apps

django-database-for-apps is a package that provides a router which chooses a database based on app name.

Installation

Install with pip or pipenv:

pip install django-database-for-apps

Add django_database_for_apps to your installed apps in your settings.py file:

INSTALLED_APPS = [
    'django_database_for_apps',
    ...
]

Configure DB routers:

DATABASE_ROUTERS = [
    'django_database_for_apps.Router'
]

Configuration

# list of apps and theirs database
DATABASE_FOR_APPS = {
    'test_project': 'default',
    '*': 'django',
}

* matches all applications so the default database might be redefined from 'default' to something else.

Optional

# allows relations between databases (default: None)
DATABASE_FOR_APPS_RELATIONS = True

License

Copyright © 2019, Piotr Roszatycki

This software is distributed under the GNU Lesser General Public License (LGPL 3 or greater).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-database-for-apps, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size django_database_for_apps-0.1.1-py2.py3-none-any.whl (5.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-database-for-apps-0.1.1.tar.gz (16.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page