在两个Django项目之间共享数据库表

编程入门 行业动态 更新时间:2024-10-24 00:20:26
本文介绍了在两个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项目之间共享数据库表

本文发布于:2023-11-25 22:38:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631631.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:两个   数据库   项目   Django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!