1

我已经将我的桌子app_aapp_b使用db_table. 我最初添加了元信息,

# app_b.models.ppy
class Table(models.Model)
# all fields
class Meta:
    db_table = 'app_a_table'
    app_label = 'app_a'

如果我在此表中进行任何更改app_b,则迁移不会在迁移文件夹下生成新的迁移文件。它说。

No changes detected in app 'app_b'

我从这个答案中尝试过,并发表了评论app_label = 'app_a'。现在迁移后,它会检测到更改并创建迁移文件。

然后我执行python manage.py migrate命令,它不断要求删除原始表app_a_table

The following content types are stale and need to be deleted:

    app_a | table

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

    Type 'yes' to continue, or 'no' to cancel: no

如何禁止此通知?我如何告诉 django 迁移该表存在于不同的应用程序中?

4

1 回答 1

2

在我使用and将我的桌子从app_a其他地方移动之后。如果我只为.app_bdb_tableapp_labelapp_a

python manage.py makemigrations app_a

此命令运行迁移app_b

于 2016-06-03T07:22:19.133 回答