2020-05-21 18:08:20 +02:00
|
|
|
class DbRouter(object):
|
|
|
|
"""
|
|
|
|
A router to control all database operations on models in the
|
|
|
|
auth application.
|
|
|
|
"""
|
|
|
|
def db_for_read(self, model, **hints):
|
|
|
|
"""
|
|
|
|
Attempts to read remote models go to local database.
|
|
|
|
"""
|
2020-09-19 14:01:30 +02:00
|
|
|
return 'local'
|
2020-05-21 18:08:20 +02:00
|
|
|
|
|
|
|
def db_for_write(self, model, **hints):
|
|
|
|
"""
|
|
|
|
Attempts to write remote models go to the remote database.
|
|
|
|
"""
|
2020-09-19 14:01:30 +02:00
|
|
|
return 'default'
|
2020-05-21 18:08:20 +02:00
|
|
|
|
|
|
|
def allow_relation(self, obj1, obj2, **hints):
|
|
|
|
"""
|
|
|
|
Allow relations involving the remote database
|
|
|
|
"""
|
|
|
|
return True
|
|
|
|
|
|
|
|
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
|
|
|
"""
|
|
|
|
Allow migrations on the remote database
|
|
|
|
"""
|
|
|
|
return True
|