【问题标题】:Getting from a model to the model type's verbose name从模型获取模型类型的详细名称
【发布时间】:2010-01-17 22:28:10
【问题描述】:

我有一个模型 FooBar 的实例 - 我如何获得归化类型 Foo Bar 以显示给用户,如果在 Meta 中设置了一个,请确保使用类的 verbose_name选项。例如:

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

  class Meta:
    verbose_name = 'Spaghetti Monster'

如何从FooBar 的实例中获取“Spaghetti Monster”?

【问题讨论】:

    标签: django django-models


    【解决方案1】:

    foobar._meta.verbose_name

    【讨论】:

    猜你喜欢
    • 2011-02-22
    • 2011-08-23
    • 2018-01-19
    • 2016-07-18
    • 2016-02-14
    • 2022-06-12
    • 1970-01-01
    • 2012-03-29
    • 2013-11-06
    相关资源
    最近更新 更多