A Django template filter that wraps around profanity-check.
Note: numpy
, scipy
, and scikit-learn
are all dependencies of profanity-check
.
-
Install with
pip
.pip install django-profanity-check
-
Add
profanity
to yourINSTALLED_APPS
.# settings.py INSTALLED_APPS = [ ..., 'profanity', ...]
-
Use it in a template!
{# ... #} {% load profanity %} {# ... #} {% with sentence='Hey, fuck you!' %} {{ sentence | censor }} {# Will result in: 'Hey, **** you!' #} {% endwith %}
- Allow custom replacement characters
- Allow custom replacement character length
- Template tests
Victor Zhou's profanity-check Python package does all the heavy lifting.
Inspired by django-profanity-filter.