V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
huisezhiyin
V2EX  ›  Python

问一个 django DATABASE_ROUTERS 的问题

  •  
  •   huisezhiyin · Jan 11, 2018 · 3073 views
    This topic created in 3028 days ago, the information mentioned may be changed or developed.
    django 的文档里显示 DATABASE_ROUTERS = ['path.to.AuthRouter', 'path.to.PrimaryReplicaRouter']
    DATABASE_ROUTERS 是一个列表里面有两个字符串
    但是我想把它变成两个实例化后的 Router 实例请问怎么实现?
    例如:

    db_router = AuthRouter(db="xxx",db2="xxxxx")

    DATABASE_ROUTERS = [ db_router ]
    1 replies    2018-01-12 08:32:22 +08:00
    julyclyde
        1
    julyclyde  
       Jan 12, 2018
    就是你现在这种写法
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   952 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 21:50 · PVG 05:50 · LAX 14:50 · JFK 17:50
    ♥ Do have faith in what you're doing.