My code has access to 3 databases. syncdb must create all of the model tables in two of the databases. I am unsure how to do this. The below does not work.
DATABASES = {
'default': {}, # empty. default is required
'db_1': { # want tables created in this
...
},
'db_2': { # want tables created in this
...
},
'other': { # do NOT want tables created in this
...
},
}
router: (a separate router handles auth tables)
import random
class OtherRouter(object):
def db_for_read(self, model, **hints):
return random.choice(['db_1', 'db_2'])
def db_for_write(self, model, **hints):
return "db_1"
def allow_relation(self, obj1, obj2, **hints):
return True
def allow_syncdb(self, db, model):
db_list = ('db_1', 'db_2')
if db in db_list:
return True
return None