Python django.db.router.routers() Examples

The following are 9 code examples of django.db.router.routers(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.db.router , or try the search function .
Example #1
Source File: signals.py    From GTDWeb with GNU General Public License v2.0 5 votes vote down vote up
def clear_routers_cache(**kwargs):
    if kwargs['setting'] == 'DATABASE_ROUTERS':
        router.routers = ConnectionRouter().routers 
Example #2
Source File: signals.py    From bioforum with MIT License 5 votes vote down vote up
def clear_routers_cache(**kwargs):
    if kwargs['setting'] == 'DATABASE_ROUTERS':
        router.routers = ConnectionRouter().routers 
Example #3
Source File: base.py    From django-tree with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #4
Source File: signals.py    From Hands-On-Application-Development-with-PyCharm with MIT License 5 votes vote down vote up
def clear_routers_cache(**kwargs):
    if kwargs['setting'] == 'DATABASE_ROUTERS':
        router.routers = ConnectionRouter().routers 
Example #5
Source File: signals.py    From python with Apache License 2.0 5 votes vote down vote up
def clear_routers_cache(**kwargs):
    if kwargs['setting'] == 'DATABASE_ROUTERS':
        router.routers = ConnectionRouter().routers 
Example #6
Source File: signals.py    From openhgsenti with Apache License 2.0 5 votes vote down vote up
def clear_routers_cache(**kwargs):
    if kwargs['setting'] == 'DATABASE_ROUTERS':
        router.routers = ConnectionRouter().routers 
Example #7
Source File: signals.py    From python2017 with MIT License 5 votes vote down vote up
def clear_routers_cache(**kwargs):
    if kwargs['setting'] == 'DATABASE_ROUTERS':
        router.routers = ConnectionRouter().routers 
Example #8
Source File: tests.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_override_database_routers(self):
        """
        Overriding DATABASE_ROUTERS should update the master router.
        """
        test_routers = [object()]
        with self.settings(DATABASE_ROUTERS=test_routers):
            self.assertEqual(router.routers, test_routers) 
Example #9
Source File: tests.py    From djongo with GNU Affero General Public License v3.0 5 votes vote down vote up
def test_override_database_routers(self):
        """
        Overriding DATABASE_ROUTERS should update the master router.
        """
        test_routers = [object()]
        with self.settings(DATABASE_ROUTERS=test_routers):
            self.assertEqual(router.routers, test_routers)