Search code examples
pythondjangointernationalizationgettext

What does '_' do in Django code?


Why does this Django code use _ in front of 'has favicon'

has_favicon = models.BooleanField(_('has favicon'))

Solution

  • 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 _