我正在从Django1.7-> Django1.8升级我的应用程序,但我无法进行任何更改甚至运行迁移,因为每当我尝试执行任何迁移操作时,我都会看到以下系统错误1.8环境
ERRORS:
content.Content.polymorphic_ctype: (fields.E306) The name 'polymorphic_content.content_set' is invalid related_name for field Content.polymorphic_ctype
HINT: Related name must be a valid Python identifier or end with a '+'
content.Tag.polymorphic_ctype: (fields.E306) The name 'polymorphic_content.tag_set' is invalid related_name for field Tag.polymorphic_ctype
HINT: Related name must be a valid Python identifier or end with a '+'
promotion.PZoneOperation.polymorphic_ctype: (fields.E306) The name 'polymorphic_promotion.pzoneoperation_set' is invalid related_name for field PZoneOperation.polymorphic_ctype
HINT: Related name must be a valid Python identifier or end with a '+'
reviews.MediaItem.polymorphic_ctype: (fields.E306) The name 'polymorphic_reviews.mediaitem_set' is invalid related_name for field MediaItem.polymorphic_ctype
HINT: Related name must be a valid Python identifier or end with a '+'
问题是这些应用中有3个是依赖项的一部分,并已在related_name
迁移中更新了3个字段中的+
以0001_initial.py
结尾,但我可以& #39;由于系统错误而向后恢复。对如何进行更新感到茫然。
答案 0 :(得分:1)
尝试使用manage.py makemigrations <appname>
为每个应用删除并重新生成迁移。
答案 1 :(得分:0)
升级后我的迁移也遇到了麻烦。如果擦除整个数据库并从头开始重新填充它是一个选项,请尝试这个(清理数据库后):
1)为每个应用运行./manage.py makemigrations app_name
2)运行./manage.py migrate
3)运行./manage.py syncdb