Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 Django 项目中,我想要两个数据库,但只有一个模型。
例如,专家数据库和漏洞利用数据库。路由器允许我根据用户组和权限写入漏洞利用数据库或专家数据库。
但是如何在两个基础上复制项目模型(在 model.py 中描述)?
您需要migrate在每个数据库上运行。使用此开关指定数据库:
migrate
--database DATABASE Nominates a database to synchronize. Defaults to the "default" database.
DATABASE在这种情况下,是您在 settings.py 字段中用于配置每个数据库的设置键。
DATABASE