2015-08-17 12:48:10 +08:00
|
|
|
class DBRouter(object):
|
|
|
|
def db_for_read(self, model, **hints):
|
2017-01-23 16:25:14 +08:00
|
|
|
if model._meta.app_label == "submission":
|
|
|
|
return "submission"
|
2015-08-17 12:48:10 +08:00
|
|
|
return "default"
|
|
|
|
|
|
|
|
def db_for_write(self, model, **hints):
|
2017-01-23 16:25:14 +08:00
|
|
|
if model._meta.app_label == "submission":
|
|
|
|
return "submission"
|
2015-08-17 12:48:10 +08:00
|
|
|
return "default"
|
|
|
|
|
|
|
|
def allow_relation(self, obj1, obj2, **hints):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def allow_migrate(self, db, app_label, model=None, **hints):
|
|
|
|
if app_label == "submission":
|
2015-08-17 20:56:42 +08:00
|
|
|
return db == app_label
|
2015-08-17 12:48:10 +08:00
|
|
|
else:
|
2015-08-17 20:56:42 +08:00
|
|
|
return db == "default"
|