我正在尝试做这项工作
管理员.py
class TapasInline(TranslatableStackedInline):
model = Tapa
can_delete = True
extra = 0
verbose_name = 'Tapas'
verbose_name_plural = 'Tapas'
fields = ('name','description','photo', 'tags')
...
class BarAdmin(TranslatableAdmin):
inlines = (TapasInline,)
...
admin.site.register(Bar,BarAdmin)
模型.py
class Tapa(TranslatableModel):
translations = TranslatedFields(
name = models.CharField(max_length=255,verbose_name='Nombre de la tapa'),
description = models.TextField(verbose_name='Descripcion de la tapa')
)
photo = models.ImageField(verbose_name='Foto de la tapa')
average_rating = models.FloatField(verbose_name='Puntuación media de la tapa',default=-1)
bar = models.ForeignKey(Bar,verbose_name='Bar')
tags = models.ManyToManyField(Tag,verbose_name='Etiquetas')
def __unicode__(self):
return self.lazy_translation_getter('name')
,但我收到此错误:
hvad.exceptions.WrongManager: To access translated fields like 'name' from an untranslated model, you must use a translation aware manager. For non-translatable models, you can get one using hvad.utils.get_translation_aware_manager.
For translatable models, use the language() method.
[姜戈==1.8]
我究竟做错了什么?我该如何解决?
提前致谢