[Django]-Django filters. is_safe doesn't work

7👍

Doc says:

This flag tells Django that if a “safe” string is passed into your filter, the result will still be “safe” and if a non-safe string is passed in, Django will automatically escape it, if necessary.

So try to pass safe value into your filter:

{{ team.biography|safe|quote }}

or user mark_safe:

from django.utils.safestring import mark_safe

@register.filter()
def quote(text):
    return mark_safe("« {} »".format(text))

And:

{{ team.biography|quote }}

This should works.

Leave a comment