1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from django import template
from post.models import AuditWord
from datetime import datetime
register = template.Library()
_bad_words = [aw.word for aw in AuditWord.objects.filter(is_published=True)]
@register.filter
def audit(value):
for word in _bad_words:
if word in value:
value = value.replace(word,'*')
return value
|
More like this
- wordbreak filter by soniiic 4 years, 2 months ago
- custom template tag sample by shinyzhu 3 years, 4 months ago
- Avoid widows using a template filter by jcroft 6 years, 3 months ago
- Truncate string after a given number of chars keeping whole words by rix 4 years, 5 months ago
- Table of Contents by dogada 5 years, 6 months ago
Comments