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

梦想的初衷 提交于 2020-01-11 17:10:10

问题


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._meta.verbose_name.title()

回答1:


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().




回答2:


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.



来源:https://stackoverflow.com/questions/4070417/django-how-to-access-the-verbose-name-of-a-model-in-its-admin-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!