【发布时间】:2014-04-26 07:08:15
【问题描述】:
这是一个非常基本的问题。我试图用谷歌搜索我能用简单的语言理解的答案。但这并没有帮助。我在Django's UserCreationForm 中遇到了下面的sn-p 代码,然后我才知道ugettext_lazy _ 存在。我不知道,如果是django specific module/function,它的目的是什么以及为什么要使用它。
SO 中有this article,对此进行了更多讨论。但我想先掌握基本面。请赐教!
from django.utils.translation import ugettext, ugettext_lazy as _
///// what is the _ means here and why is it used
class UserCreationForm(forms.ModelForm):
"""
A form that creates a user, with no privileges, from the given username and
password.
"""
error_messages = {
'duplicate_username': _("A user with that username already exists."),
'password_mismatch': _("The two password fields didn't match."),
}
【问题讨论】:
标签: django django-models django-views