Request Method: GET
Request URL: http://localhost:8000/blog/blog-title/
Django Version: 1.10.8
Exception Type: ValueError
Exception Value:
'title_en' is not in list
Exception Location: /lib/python3.6/site-packages/django/db/models/query.py in __init__, line 1715
Python Executable: /bin/python
Python Version: 3.6.5在安装django-modeltranslation之后,我在我的django站点上得到了这个错误。我尝试过在translationOptions中添加字段。我还尝试了makemigration和迁徙。这将在表中添加title_en,但是它不会在前面呈现博客。在添加django-modeltranslation之前,博客是正确呈现的,没有任何错误。
发布于 2018-09-15 21:05:32
当您向已经包含数据的现有模型添加model-translation时,数据仍然存储在原始列(例如title)中,但不会复制到新的默认语言列title_en中。
因此,如果要迁移现有数据,在迁移makemigrations和migrate之后,还应该运行update_translation_fields,它会将所有现有值复制到空的默认语言列中。
您可以多次运行此操作(当稍后将翻译添加到其他模型时),它仅在_en字段为空时复制值。
https://stackoverflow.com/questions/52339451
复制相似问题