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.

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

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page