修改判题数据库
This commit is contained in:
30
oj/db_router.py
Normal file
30
oj/db_router.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# coding=utf-8
|
||||
|
||||
|
||||
class DBRouter(object):
|
||||
def db_for_read(self, model, **hints):
|
||||
if model._meta.app_label == 'submission':
|
||||
return 'submission'
|
||||
return "default"
|
||||
|
||||
def db_for_write(self, model, **hints):
|
||||
if model._meta.app_label == 'submission':
|
||||
return 'submission'
|
||||
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":
|
||||
if db == "submission":
|
||||
r = True
|
||||
else:
|
||||
r = False
|
||||
else:
|
||||
if db == "default":
|
||||
r = True
|
||||
else:
|
||||
r = False
|
||||
print db, app_label, r
|
||||
return r
|
||||
Reference in New Issue
Block a user