[Django] gettext_lazy について
gettext_lazyとは何でしょう?
Djangoでカスタムのユーザー( AbstractUser )を使うとき、
from django.utils.translation import gettext_lazy as _
class User(AbstractBaseUser, PermissionsMixin):
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."),
},
)
# 以下略
例えばこんな感じでやると思うのですが、gettext_lazyはどのような機能の関数なのでしょうか?
2 likes