Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Django filter to transform HTML to a string with tags replaced by white spaces
from django import template
from django.utils.html import format_html
from django.template.defaultfilters import stringfilter
register = template.Library()
def convert_tags_to_space(value):
import re
return re.sub('<.*?>', ' ', value).strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment