您的位置:首页 > 编程语言 > Go语言

基于 Django1.10 文档的深入学习(6)—— Translation 之 short_description

2017-04-24 23:31 621 查看
Model methods
short_description
attribute values


For model methods, you can provide translations to Django and
the admin site
with the
short_description
attribute:

from django.db import models

class MyThing(models.Model):
kind = models.ForeignKey(
ThingKind,
on_delete=models.CASCADE,
related_name='kinds',
verbose_name=_('kind'),
)

def is_mouse(self):
return self.kind.type == MOUSE_TYPE
is_mouse.short_description = 'Is it a mouse?'


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐