删除未使用的模型,陈旧的内容类型提示
Deleting unused Models, stale content types prompt
我正在从我们的 Django 网站中删除不必要的 table 和模型。在调用 migrations.DeleteModel(...) 之前我已经删除了所有外键引用,但是当我 运行 迁移时我仍然收到以下提示:
The following content types are stale and need to be deleted:
myapp | MyDeletedModel
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: yes
我很困惑为什么我会收到此提示有没有什么方法可以在我们上线时停止显示此提示?我们使用 CI 环境,没有用户可以回答 "yes" 或 "no"
谢谢
内容类型框架包含对模型 table 的引用。在这种情况下,您有一个对刚刚删除的 table 的陈旧引用。回答 yes
并删除陈旧的内容类型是完全安全的。如果你重命名一个 table 并有一个 GenericForeignKey
指向它,那将是另一回事,在这种情况下,其他对象将有一个 ForeignKey
指向那个 ContentType
,并且delete 会沿着这些关系级联。
在实时环境中,您可以通过--noinput
选项来抑制这个提示。但是,它将默认为 no
。放一些陈旧的 contenttypes
通常不是问题。
我正在从我们的 Django 网站中删除不必要的 table 和模型。在调用 migrations.DeleteModel(...) 之前我已经删除了所有外键引用,但是当我 运行 迁移时我仍然收到以下提示:
The following content types are stale and need to be deleted:
myapp | MyDeletedModel
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: yes
我很困惑为什么我会收到此提示有没有什么方法可以在我们上线时停止显示此提示?我们使用 CI 环境,没有用户可以回答 "yes" 或 "no"
谢谢
内容类型框架包含对模型 table 的引用。在这种情况下,您有一个对刚刚删除的 table 的陈旧引用。回答 yes
并删除陈旧的内容类型是完全安全的。如果你重命名一个 table 并有一个 GenericForeignKey
指向它,那将是另一回事,在这种情况下,其他对象将有一个 ForeignKey
指向那个 ContentType
,并且delete 会沿着这些关系级联。
在实时环境中,您可以通过--noinput
选项来抑制这个提示。但是,它将默认为 no
。放一些陈旧的 contenttypes
通常不是问题。