Django Model

email = models.EmailField(_('email address'), unique=True)
What does the _(‘email address’) means? and where it came from?
I am trying to override the email field on django user model, but I cant find any explanation about that.
Thank you!

The first positional argument for an EmailField is the label. The method _() is typically gettext_lazy or gettext but aliased to _. This is done via (specific example in the docs):

from django.utils.translation import gettext_lazy as _

If you go to the top of that file which has the code, you should find that import statement. The function gettext_lazy is used to support internationalization of text. Please checkout the docs for the details.

As an aside, this should have been posted in the Using Django section. Django Internals is used for discussion of Django’s implementation and the active development of Django.

1 Like

Just a quick aside - if you see a pencil icon to the right of the subject line (“Django Model” in this case), you can click on it and recategorize the topic.

I did not know that, thank you for sharing!