2
在我的应用程序队/ templatetags/teams_extras.py我有这样的过滤器Django过滤器。 is_safe不起作用
from django import template
register = template.Library()
@register.filter(is_safe=True)
def quote(text):
return "« {} »".format(text)
所以我用它为我的观点队/模板/团队/ show.html
{% extends './base.html' %}
{% load static %}
{% load teams_extras %}
...
<b>Bio :</b> {{ team.biography|quote }}
...
但是,这是我的网页上的结果:
« <p>The Miami Heat are an American professional basketball team based in Miami. The Heat compete in the National Basketball Association as a member of the league's Eastern Conference Southeast Division</p> »
为什么? 谢谢
尝试这个'返回'«{}»“.format(text)' –
我有这个:««
迈阿密热火队是一支美国职业篮球队,总部设在迈阿密。热火在美国国家篮球协会参加东部联盟东南联盟成员
»' – Alexandre您可以使用过滤器安全[doc](https://docs.djangoproject.com/en/1.10/ref/templates/ builtins /#safe) –