This is a very basic question. I tried to google to find answers that I could understand in simple language. but that did not help. I came across the below snippet of code in Django's UserCreationForm
and only then I know something ugettext_lazy
_
exists. I have no idea, if it is a django specific module/function
, what's its purpose and why it should be used.
There is this article in SO, which discuss more on this. but I want to grasp the fundamentals first. Please enlighten me!
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."),
}