3

我正在使用 Mezzanine 开发一个网站,但在尝试为其配置 modelTranslation 插件时遇到问题。我正在使用 Django 1.8.9 和 Mezzanine 4.0.1,django_modeltranslation 0.11。

我有一个带有一些字段的模型类 GenericContent :

class GenericContent(models.Model):
    image_footer = RichTextField(blank=True)
    video_footer = RichTextField(blank=True)
    summary = RichTextField(blank=True)

class BasicContent(Page, RichText, GenericContent):
    pass

在 basicContent 应用程序的 translation.py 文件中,我们有以下 modelTranslation 翻译定义:

class TranslatedGenericContent(TranslationOptions):
    fields = ('summary',
              'image_footer',
              'video_footer',)

class TranslatedBasicContent(TranslationOptions):
    pass

translator.register(GenericContent, TranslatedGenericContent)
translator.register(BasicContent, TranslatedBasicContent)

使用此配置,它不会显示错误,但 basicContent 不会被翻译(从 genericContent 继承的字段已注册进行翻译,但在 basicContent 中它们不会被翻译,父类中的任何其他字段也不会被翻译[页和 RichText],它们是夹层包含的类并已注册翻译)。

如果我尝试修改 translation.py 文件:

class TranslatedGenericContent(TranslationOptions):
    fields = ('summary',
              'image_footer',
              'video_footer',)

translator.register(GenericContent, TranslatedGenericContent)
translator.register(BasicContent, TranslatedGenericContent)

尝试运行python manage.py sync_translation_fields时,此其他配置会给出错误

basicContent.BasicContent.image_footer_en: (models.E006) The field 'image_footer_en' clashes with the field 'image_footer_en' from model 'basicModels.genericcontent'.
basicContent.BasicContent.image_footer_es: (models.E006) The field 'image_footer_es' clashes with the field 'image_footer_es' from model 'basicModels.genericcontent'.
basicContent.BasicContent.summary_en: (models.E006) The field 'summary_en' clashes with the field 'summary_en' from model 'basicModels.genericcontent'.
basicContent.BasicContent.summary_es: (models.E006) The field 'summary_es' clashes with the field 'summary_es' from model 'basicModels.genericcontent'.
basicContent.BasicContent.video_footer_en: (models.E006) The field 'video_footer_en' clashes with the field 'video_footer_en' from model 'basicModels.genericcontent'.
basicContent.BasicContent.video_footer_es: (models.E006) The field 'video_footer_es' clashes with the field 'video_footer_es' from model 'basicModels.genericcontent'.

你有没有遇到过这个问题?我正在寻找解决此问题的方法。任何帮助,将不胜感激!

4

0 回答 0