Skip to content

Instantly share code, notes, and snippets.

@dinopetrone
Created December 3, 2012 17:05
Show Gist options
  • Save dinopetrone/4196375 to your computer and use it in GitHub Desktop.
Save dinopetrone/4196375 to your computer and use it in GitHub Desktop.
class MasterSlaveRouter(object):
def db_for_read(self, model, **hints):
return 'slave'
def db_for_write(self, model, **hints):
return 'master'
def allow_relation(self, obj1, obj2, **hints):
db_list = ('master', 'slave')
if obj1.state.db in db_list and obj2.state.db in db_list:
return True
return None
def allow_syncdb(self, db, model):
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment