Django 模板:过滤另一个
Django template: filter in an other
我怎样才能在另一个过滤器中放置一个过滤器。我已经在 blog_extras.py
中创建了一个名为 'titl' 的过滤器:
@register.filter(is_safe=True)
def titl(texte):
return " %s " % texte.title()
然后我将它加载到我的模板中:
{% load blog_extras %}
然后我这样做:
{%for categorie in Categories%}
<a href="#"><div class="categorie">
<center><h1 class="c">{{ {{categorie}} |标题 }}</h1></center><br>
</div></a>
{% 空的 %}
<h1>博客就是建设</h1>
{%endfor%}
但出现错误消息:
TemplateSyntaxError at /blog/menu/ Could not parse the remainder: '{{categorie' from '{{categorie'
你的牙套太多了。应该是
{{categorie|titl}}
而不是{{ {{categorie}} | titl }}
我怎样才能在另一个过滤器中放置一个过滤器。我已经在 blog_extras.py
中创建了一个名为 'titl' 的过滤器:
@register.filter(is_safe=True)
def titl(texte):
return " %s " % texte.title()
然后我将它加载到我的模板中:
{% load blog_extras %}
然后我这样做:
{%for categorie in Categories%}
<a href="#"><div class="categorie">
<center><h1 class="c">{{ {{categorie}} |标题 }}</h1></center><br>
</div></a>
{% 空的 %}
<h1>博客就是建设</h1>
{%endfor%}
但出现错误消息:
TemplateSyntaxError at /blog/menu/ Could not parse the remainder: '{{categorie' from '{{categorie'
你的牙套太多了。应该是
{{categorie|titl}}
而不是{{ {{categorie}} | titl }}