O'Reilly logo
  • Alexander Kruman thinks this is interesting:

from django.template.defaultfilters import linebreaksbr, urlize @register.filter def urlize_and_linebreaks(text): return linebreaksbr( urlize(text, autoescape=True),autoescape=True) Then: {{ comment|urlize_and_linebreaks }} Would be equivalent to: {{ comment|urlize|linebreaksbr }}

From

Cover of Mastering Django: Core

Note

from django.template.defaultfilters import linebreaksbr, urlize
@register.filter
def urlize_and_linebreaks(text):
return linebreaksbr( urlize(text, autoescape=True),autoescape=True)