Skip to content

Instantly share code, notes, and snippets.

@markng
Created November 6, 2012 17:25
Show Gist options
  • Save markng/4026171 to your computer and use it in GitHub Desktop.
Save markng/4026171 to your computer and use it in GitHub Desktop.
wordpress db router
class WordpressRouter(object):
""" Database router - for the moment, everything to default except the wordpress app, which has its own setting """
def db_for_read(self, model, **hints):
if model._meta.app_label == 'wordpress':
return 'wordpress'
return None
def db_for_write(self, model, **hints):
if model._meta.app_label == 'wordpress':
return 'wordpress'
return None
def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label == 'wordpress' or obj2._meta.app_label == 'wordpress':
return True
return None
def allow_syncdb(self, db, model):
if model._meta.app_label == 'south':
return True
if db == 'wordpress':
return False
elif model._meta.app_label == 'wordpress':
return False
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment