【发布时间】:2016-03-04 02:12:54
【问题描述】:
我已经尝试了所有找到的方法:
Can stale content types be automatically deleted in Django?
Deleting unused Models, stale content types prompt
InvalidBasesError: Cannot resolve bases for [<ModelState: 'users.GroupProxy'>]
Django Wagtail CMS migrate: Cannot resolve bases for [<ModelState: 'app.CustomPage'>
所以这是我的问题:我有:
- 一个
ComicBook,它有一个多对多Planche的 - 一个
Planche,它有一个多对多Bande的 - 一个
Bande,它有一个多对多Vignette的 - ...以及更深的三个层次(这并不重要,它始终是相同的原则)
我需要在多对多表之间添加“importance”字段,以便能够对关系进行自定义排序。这样我就创建了
-
ComicBookPlanche是带有字段importance的多对多表 -
PlancheBande是一个带有字段importance的多对多表
在我决定将 ComicBook 重命名为 Book 之前,一切都运行良好。从现在开始,我总是收到消息django.db.migrations.state.InvalidBasesError: Cannot resolve bases for...
我什至尝试删除所有表格 和 迁移文件夹,没有任何改变...我尝试评论我的应用程序 -> 很棒然后取消评论并仍然:
django.db.migrations.state.InvalidBasesError:
Cannot resolve bases for
[<ModelState: 'main.TexteLongTextesThrough'>,
<ModelState: 'main.TexteCourtTextesThrough'>,
<ModelState: 'main.VignetteBullesThrough'>,
<ModelState: 'main.LivrePlanchesThrough'>]
我要生气了。所以这就是我所做的:
- 全新的应用程序
-
makemigrations然后migrate-> 身份验证、管理员、会话、站点创建没有问题 - 复制/粘贴我的
models.py没有admin.py。
makemigrations -> 完美:
Migrations for 'main':
0001_initial.py:
- Create model Bande
- Create model BandeVignette
- Create model Bulle
- Create model ContenuCourt
- Create model ContenuLong
- Create model Langue
- Create model Livre
- Create model Personne
- Create model Planche
- Create model PlancheBande
- Create model TexteCourt
- Create model TexteLong
- Create model Vignette
- Add field description to planche
- Add field planches to livre
然后migrate -> 完美:
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: sessions, admin, sites, auth, contenttypes, main
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying main.0001_initial... OK
Process finished with exit code 0
然后复制/粘贴我的admin.py 然后makemigrations -> 完美:
Migrations for 'main':
0002_livreplanchesthrough_textecourttextesthrough_textelongtextesthrough_vignettebullesthrough.py:
- Create proxy model LivrePlanchesThrough
- Create proxy model TexteCourtTextesThrough
- Create proxy model TexteLongTextesThrough
- Create proxy model VignetteBullesThrough
Process finished with exit code 0
然后每次我尝试migrate 时,它都会一直问我这个问题,无论我回答“是”还是“否”:
>>> migrate
Operations to perform:
Synchronize unmigrated apps: staticfiles, messages
Apply all migrations: sessions, admin, sites, auth, contenttypes, main
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
The following content types are stale and need to be deleted:
main | textelong_textes
main | textecourt_textes
main | livre_planches
main | vignette_bulles
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
Process finished with exit code 0
我该怎么做才能让他停止询问,问题是什么?
【问题讨论】:
标签: python django django-models django-modeladmin django-model-utils