Py学习  »  问与答

菜鸟求助 last_name = models.CharField(_('last name'), max_length=30, blank=True)

msliudongsheng • 11 年前 • 5142 次点击  

last_name = models.CharField(_('last name'), max_length=30, blank=True)

field中_('last name') 这个表示的是什么意思

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/549
文章 [ 3 ]  |  最新文章 11 年前
Py站长
Reply   •   1 楼
Py站长    11 年前

@msliudongsheng 这是一种多国语言版本的写法,你在语言配置文件里写上 balala的定义,_('')就会寻找相应的语言所对应的定义,以此来实现多语言化。

msliudongsheng
Reply   •   2 楼
msliudongsheng    11 年前

@Django中国社区 我是想问_('balala') 下划线括号是什么语法?比较低级

Py站长
Reply   •   3 楼
Py站长    11 年前
verbose_name
Field.verbose_name
A human-readable name for the field. If the verbose name isn’t given, Django will automatically create it using the field’s attribute name, converting underscores to spaces. See Verbose field names.

https://docs.djangoproject.com/en/dev/ref/models/fields/