在两个Django项目之间共享数据库表 [英] sharing database table between two django projects

查看:298
本文介绍了在两个Django项目之间共享数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个不同的Django项目,它们打算并行运行并执行完全不同的事情。

I have two different Django projects that are meant to run in parallel and do pretty different things.

但是它们需要共享一个公共数据库表Client表..

However they need to share a common database table, the Client table..

两个项目都包含多个应用程序,这些应用程序需要包含映射到该客户端模型的外键。.

Both projects contains multiple apps that needs to contain foreign keys mapped to that Client model..

我不确定哪种方法最好。.

I'm not sure what would be the best approach..

推荐答案

不幸的是,Django对多个数据库的支持不是支持跨数据库关系。您可以在其中一个系统上进行伪造(即引用了表,但自己处理了键引用),但是您需要非常小心地记录正在执行的操作,以确保在应用程序中保持引用完整性。是伪造它。

Unfortunately, Django's support for multiple databases does not support cross-database relations. You could fake this on one of the systems (ie. have the table referenced, but handle the key refs yourself), but you would need to be very careful to document what you are doing to make sure you maintain referential integrity in the app that is 'faking' it.

这篇关于在两个Django项目之间共享数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆