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

最低0.47元/天 解锁文章
6865





