Django: Stop filter from always escaping HTML

0 Comments

The majority of the time, Django's automatic escaping of filter output is very handy. But sometimes you actually want the output to be unescaped HTML, so for that you can use the "is_safe" property.

1.@register.filter
2.def add_xx(value):
3.  return '<%s>Blah blah blah</%s>' % (value, value)
4.add_xx.is_safe = True

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog