36👍
✅
If you look in the import statements, you’ll find that they tied _ to a function that turns stuff into unicode and localizes it by writing:
from django.utils.translation import ugettext_lazy as _
11👍
_
in Django is a convention that is used for localizing texts. It is an alias for ugettext_lazy. Read Lazy translation in the docs for more info about it.
- Image Conversion – Cannot write mode RGBA as JPEG
- Acessing POST field data without a form (REST api) using Django
- Django – Change a ForeignKey relation to OneToOne
- Getting Django to serialize objects without the "fields" field
9👍
_
is usually a macro/function from gettext, it means the argument is a localized string. this is not limited to Django or Python. in fact gettext is originally a package for C programs, ported to many other languages over the years.
Source:stackexchange.com