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
  • 320
  • 1
  • 6
  • 14

1 Answers1

4

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

Iain Shelvington
  • 31,030
  • 3
  • 31
  • 50