What does '_' do in Django code?

前端 未结 3 790
北海茫月
北海茫月 2021-02-20 13:41

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

has_favicon = models.BooleanField(_(\'has favicon\'))
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-20 14:26

    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 _
    

提交回复
热议问题