0

I am a starter in python. Now I am working on a Django project. I saw many lines of code containing _('password'), _('last_login') etc. Check the code below:


    username = models.CharField(
        _('username'),
        max_length=150,
        unique=True,
        help_text=_('Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.'),
        validators=[username_validator],
        error_messages={
            'unique': _("A user with that username already exists."),
        },
    )

What is the use of _('username')?

Atom
  • 132
  • 3
  • 11

1 Answers1

4

In Django the gettext function is often imported as _ for convenience

Iain Shelvington
  • 26,159
  • 1
  • 24
  • 40