开发者

Getting from a model to the model type's verbose name

I've got an instance of a model FooBar - how do I get the naturalised type Foo Bar for display to the user, making sure to 开发者_运维百科use the class's verbose_name if one is set in the Meta options. e.g.:

class FooBar(models.Model):
  title = models.CharField(max_length = 100)

  class Meta:
    verbose_name = 'Spaghetti Monster'

How do I get 'Spaghetti Monster' from an instance of a FooBar?


foobar._meta.verbose_name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜