29 lines
753 B
Text
29 lines
753 B
Text
|
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.
|
||
|
"""
|
||
|
return 'default'
|
||
|
|
||
|
def db_for_write(self, model, **hints):
|
||
|
"""
|
||
|
Attempts to write remote models go to the remote database.
|
||
|
"""
|
||
|
return 'master'
|
||
|
|
||
|
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
|