I'd like to get rid of the follow message I get when running migrations:
The following content types are stale and need to be deleted:
appname | modelname
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?
It seems cleaner to encode the decision to delete or not delete in the migrations.
What's the cleanest way to detect and delete stale ContentTypes as part of my migrations? Why is it not done automatically if ContentTypes are created automatically?
答案 0 :(得分:0)
迁移数据库时,您可以将--noinput
添加到manage.py
,如下所示:
manage.py migrate --noinput
这样,用户就不会被问到。
答案 1 :(得分:0)
尝试一下以安全删除
python manage.py remove_stale_contenttypes