- commit
- 6ac318305cd2080b3f6038ce38b75030a02503b3
- parent
- aff583d84e6d5e36ee358c044ec89e5b53eec044
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-09-15 08:45
rm db_routers
Diffstat
| D | utils/db_routers.py | 49 | ------------------------------------------------- |
1 files changed, 0 insertions, 49 deletions
diff --git a/utils/db_routers.py b/utils/db_routers.py
@@ -1,49 +0,0 @@1 -1 from django.apps import apps2 -1 from django.conf import settings3 -14 -15 -1 class AppDBRouter:6 -1 """Route specific apps to specific databases.7 -18 -1 This router makes no statements about other apps, i.e. there is no9 -1 guarantee that an app has exclusive access to a database. While10 -1 database access is routed to 'default' by default, migrations are11 -1 executed on all databases.12 -113 -1 Example configuration::14 -115 -1 APP_DB_ROUTER = {16 -1 'some.app': 'database1',17 -1 'other.app': 'database2',18 -1 }19 -1 """20 -121 -1 def db_for_read(self, model, **hints):22 -1 app_label = model._meta.app_label23 -1 return settings.APP_DB_ROUTER.get(app_label)24 -125 -1 def db_for_write(self, model, **hints):26 -1 return self.db_for_read(model, **hints)27 -128 -1 def allow_migrate(self, db, app_label, model_name=None, **hints):29 -1 _db = settings.APP_DB_ROUTER.get(app_label)30 -1 if _db is not None:31 -1 return db == _db32 -133 -134 -1 class ModelDBRouter:35 -1 def db_for_read(self, model, **hints):36 -1 model_label = model._meta.label37 -1 return settings.MODEL_DB_ROUTER.get(model_label)38 -139 -1 def db_for_write(self, model, **hints):40 -1 return self.db_for_read(model, **hints)41 -142 -1 def allow_migrate(self, db, app_label, model_name=None, **hints):43 -1 if model_name:44 -1 model = apps.get_model(app_label, model_name)45 -1 _db = self.db_for_write(model)46 -1 if _db:47 -1 return db == _db48 -1 elif db in settings.MODEL_DB_ROUTER.values():49 -1 return False