V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2018-01-11 12:57:28 +08:00 · 2464 次点击
    这是一个创建于 2290 天前的主题,其中的信息可能已经有所发展或是发生改变。
    django 的文档里显示 DATABASE_ROUTERS = ['path.to.AuthRouter', 'path.to.PrimaryReplicaRouter']
    DATABASE_ROUTERS 是一个列表里面有两个字符串
    但是我想把它变成两个实例化后的 Router 实例请问怎么实现?
    例如:

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

    DATABASE_ROUTERS = [ db_router ]
    1 条回复    2018-01-12 08:32:22 +08:00
    julyclyde
        1
    julyclyde  
       2018-01-12 08:32:22 +08:00
    就是你现在这种写法
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5325 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:52 · PVG 16:52 · LAX 01:52 · JFK 04:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.