アプリを複数のデータベースに接続する必要がありますが、成功していません。
settings.py でデータベースを定義した後、何をする必要がありますか? 正しいことをしたかどうかはわかりませんが、routers.py を作成し、次のコードを追加しました。
class DBRouter(object):
"""A router to control all database operations on models in
the contrib.auth application"""
def db_for_read(self, model, **hints):
if hasattr(model,'teste'):
return model.connection_name
return None
def db_for_write(self, model, **hints):
if hasattr(model,'teste'):
return model.connection_name
return None
def allow_syncdb(self, db, model):
if hasattr(model,'teste'):
return model.connection_name == db
return db == 'default'
syncdb を実行する必要がありますか? 私は今何をしなければなりませんか?