自动标记模型名称/属性以进行翻译
有没有一种方法可以自动标记所有模型名称和属性以进行翻译,而无需在每个模型名称和属性上指定 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')
Is there any way one could automatically mark all model names and attributes for translation, without specifying verbose_name/_plural on each one of them?
Doesn't feel very DRY to do this every time:
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')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论