我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用django.db.router.routers()。
def clear_routers_cache(**kwargs): if kwargs['setting'] == 'DATABASE_ROUTERS': router.routers = ConnectionRouter().routers
def __init__(self): self.data = [] self.router = router.routers[0] self.rows_count = 0 n = 1 for i in self.siblings_per_level: n *= i self.rows_count += n if not os.path.exists(self.results_path): os.makedirs(self.results_path)
def setUp(self): self.old_routers = router.routers router.routers = [OtherRouter()]
def tearDown(self): router.routers = self.old_routers