Created
November 6, 2012 17:25
-
-
Save markng/4026171 to your computer and use it in GitHub Desktop.
wordpress db router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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