Django - How to access the verbose_name of a Model in its Admin Module?

前端 未结 2 457
梦如初夏
梦如初夏 2021-02-01 15:47

How to access the verbose_name of a Model in its Admin Module? We can access the same if we have an instance of that model like below.

instance._met         


        
相关标签:
2条回答
  • 2021-02-01 15:52

    Model._meta.verbose_name.title() returns verbose name with First Character Uppercase while Model._meta.verbose_name_raw property returns the verbose name you wrote in the model class.

    0 讨论(0)
  • 2021-02-01 16:00

    Model._meta.verbose_name.title()

    and

    Model._meta.verbose_name_plural.title()

    return singular and plural Model's verbose names accordingly. There's also Model._meta.verbose_name_raw property, it seems to return unicode string for me, while verbose_name.title() returns a normal string, but I'm not sure what's the real difference between this and verbose_name.title().

    0 讨论(0)
提交回复
热议问题