多个应用程序中的模型
Models in multiple applications
我的问题是 this:Can 我在几个应用程序中拆分了我的数据库架构?如果是这样,我如何首先告诉 makemigrations model.py 运行?我不想在模型之间出现外键问题。
app1
model.py
app2
model.py
如果您的 app2
ForeignKey
和 app1
则生成的迁移将包含对 app1
.
中的迁移的依赖
This means that when you run the migrations, the app1
migration runs first and creates the table the ForeignKey
references, and then the migration that makes the ForeignKey column runs afterwards and creates the constraint.
更多信息Dependencies
我的问题是 this:Can 我在几个应用程序中拆分了我的数据库架构?如果是这样,我如何首先告诉 makemigrations model.py 运行?我不想在模型之间出现外键问题。
app1
model.py
app2
model.py
如果您的 app2
ForeignKey
和 app1
则生成的迁移将包含对 app1
.
This means that when you run the migrations, the
app1
migration runs first and creates the table theForeignKey
references, and then the migration that makes the ForeignKey column runs afterwards and creates the constraint.
更多信息Dependencies