class MyAppRouter(object): """A router to control all database operations on models in the myapp application""" def db_for_read(self, model, **hints): "Point all operations on myapp models to 'other'" if model._meta.app_label == 'myapp': return 'other' return None
@staticmethod
def db_for_read(model, **hints):
https://docs.djangoproject.com/en/1.3/topics/db/multi-db/#topics-db-multi-db-routing
"""
Then, in your settings file, add the following (substituting path.to.
with the actual python path to the module where you define the
routers):
DATABASE_ROUTERS = ['path.to.MyAppRouter', 'path.to.MasterSlaveRouter']
"""
DATABASE_ROUTERS is supposed to be a list of strings, each string
denoting the python path and class name of a DB router class. You are
setting it to a list of klasses.
Django will take care of instantiating instances of the DB router
classes as needed.
Cheers
Tom