问题
Django urlize docs say:
The
urlizefilter also takes an optional parameterautoescape. IfautoescapeisTrue, the link text and URLs will be escaped using Django's built-inescapefilter. The default value for autoescape isTrue.
I'd like to use this parameter, but the documentation says nothing about how to actually pass a keyword argument to a template filter. Is it possible, and if so, how do I do that?
回答1:
Apparently urlize gets that keyword argument from current autoescape settings, so the way to go seems like
{% autoescape off %}{{ value|force_escape|urlize }}{% endautoescape %}
(if you still want to escape the value)
来源:https://stackoverflow.com/questions/6316156/how-do-i-pass-djangos-urlize-template-filter-its-autoescape-parameter