简体   繁体   English

| _在Django模板标记中

[英]|_ in django template tag

I work as content manager and have access to CMS of a website. 我是内容经理,可以访问网站的CMS。 It is built with Django. 它是用Django构建的。 In some templates objects are taken as {{object_name.object_atribute|_}} . 在某些模板中,对象被当作{{object_name.object_atribute|_}} I cannot understand what |_ do 我不明白|_做什么

In django template filters spesified with " | " like; 在django模板中,过滤器以“ |”开头; {{object_name.object_atribute|default_if_none:"nothing" }} . {{object_name.object_atribute|default_if_none:"nothing" }} What this will do is if object_name.object_atribute is not empty it will render object_name.object_atribute and if its empty it will render "nothing". 这样做是如果object_name.object_atribute不为空,则将呈现object_name.object_atribute ,如果为空,则将呈现“无”。 This is built-in template tag . 这是内置模板标签

Coming to your problem , Django does not have built in " _ " tag. 遇到您的问题,Django没有内置的“ _”标记。 "_" generally related with translation , probably they wrote a custom template tag and give name to it as " _ ". “ _”通常与翻译有关,可能是他们编写了一个自定义模板标签 ,并将其命名为“ _”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM