Django代码中的'_'是什么? [英] What does '_' do in Django code?
本文介绍了Django代码中的'_'是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这个Django代码在'has favicon'前面使用_
Why does this Django code use _
in front of 'has favicon'
has_favicon = models.BooleanField(_('has favicon'))
推荐答案
如果您查看import语句,您会发现它们将_绑定到一个函数,该函数将东西转换成unicode并通过编写将其本地化:
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 _
这篇关于Django代码中的'_'是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文