2015-07-20 177 views
0

我正在從Django1.7-> Django1.8升級我的應用程序,但我無法進行任何更改,甚至無法運行遷移,因爲每當我看到以下系統錯誤試圖在1.8環境中執行任何遷移操作升級到Django1.8 - 無效related_name的字段

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依賴的一部分,並且已經更新了3場的related_name0001_initial.py遷移與+結束,但由於系統錯誤,我無法恢復原狀。如何進行更新時遇到種種損失。

回答

1

嘗試使用manage.py makemigrations <appname>刪除並重新生成每個應用的遷移。

0

升級後我也遇到了遷移問題。如果擦你的整個數據庫,並從從頭重新填充它是一個選項,試試這個(清潔DB後): 1)對於每個應用 2)運行./manage.py migrate 3)運行./manage.py syncdb

運行 ./manage.py makemigrations app_name