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

来源:互联网 发布:js canva绘制渐变色线 编辑:程序博客网 时间:2024/06/04 23:29

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 modelsclass 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?'

这里写图片描述

0 0
原创粉丝点击