A better way of dealing w/profanity - disemvowel it!
From Wikipedia, "disemvoweling is a technique used to censor unwanted postings such as spam, internet trolling, rudeness or criticism and yet maintain some transparency, both of the act and the underlying word." Credit: Boing Boing
This original sentence: In the fields of Internet discussion and forum moderation, disemvoweling (also spelled disemvowelling) is the removal of vowels from text. would be disemvowelled to look like this: n th flds f ntrnt dscssn nd frm mdrtn, dsmvwlng (ls splld dsmvwllng) s th rmvl f vwls frm txt.
body_input = form.cleaned_data["body"]
body_input = disemvowel_profanity(body_input)
1 2 3 4 5 6 7 8
from django.conf import settings import re def disemvowel_profanity(value): for w in settings.PROFANITIES_LIST: if value.find(w)!=-1: value = value.replace(value, re.sub(r'[AEIOUYaeiouy]', '', value)) return value
More like this
- Serializer factory with Django Rest Framework by julio 3 months, 1 week ago
- Image compression before saving the new model / work with JPG, PNG by Schleidens 4 months ago
- Help text hyperlinks by sa2812 4 months, 3 weeks ago
- Stuff by NixonDash 7 months ago
- Add custom fields to the built-in Group model by jmoppel 9 months, 1 week ago