用于翻译的自动标记模型名称/属性

时间:2010-06-17 07:10:01

标签: django django-models translation dry

有没有办法可以自动标记所有模型名称和翻译属性,而不在每一个上指定verbose_name / _plural?

每次都这样做感觉不是很干:

class Profile(models.Model):
    length = models.IntegerField(_('length'))
    weight = models.IntegerField(_('weight'))
    favorite_movies = models.CharField(_('favorite movies'), max_length=100)
    favorite_quote = models.CharField(_('favorite quote'), max_length=30)
    religious_views = models.CharField(_('religious views'), max_length=30)
    political_views = models.CharField(_('political views'), max_length=30)

    class Meta:
        verbose_name = _('profile')
        verbose_name_plural = _('profiles')

0 个答案:

没有答案