我在我的项目中使用hvad用于django-cms中的多语言模型两个应用程度Degree,Domain 在我的setting.py中使用了两种语言
LANGUAGES = [
('en', _('English')),
('fr', _('French')),
]
Degree model.py采用多语言结构:
class Degree(TranslatableModel):
translations = TranslatedFields(
degree_nm = models.CharField(max_length=100, verbose_name =_('Degree Name')),
des = models.TextField(verbose_name = _('Description')),
title = models.CharField(max_length=512, verbose_name=_('Title')),
slug = models.SlugField(max_length=512, verbose_name=_('Slug')),
created_date = models.DateTimeField(auto_now_add=True, blank=True, null=True),
updated_date = models.DateTimeField(auto_now=True, blank=True, null=True),
created_by = models.ForeignKey(User, blank=True, null=True, editable=False),
)
现在在域应用程序中在django-cms中建立外键关系 Domain的models.py就是我不使用TranslatableModel,使用普通模型
class Domain(TranslatableModel):
translations = TranslatedFields(
degree = models.ForeignKey('degree.Degree')
domain_nm = models.CharField(max_length=100, verbose_name ='Domain Name')
des = models.TextField(verbose_name = 'Description')
title = models.CharField(max_length=512, verbose_name='Title')
slug = models.SlugField(max_length=512, verbose_name='Slug')
created_date = models.DateTimeField(auto_now_add=True, blank=True, null=True)
updated_date = models.DateTimeField(auto_now=True, blank=True, null=True)
created_by = models.ForeignKey(User, blank=True, null=True, editable=False)
)
因此,当我在django-cms中添加域中的记录时,它只显示当前语言条目。我希望同时获得英语和法语的记录。
提前致谢!!!