django-profanity-filter

Django Profanity Filter is a simple Django app that introduces a range of template tags and filters and model validators that remove or censor inappropriate language.


Keywords
python, template, django, jinja2, tags, filter, filters, profanity, swearing
Licenses
BSD-3-Clause/Zed
Install
pip install django-profanity-filter==0.2.1

Documentation

Django Profanity Filter

PyPI license PyPI PyPI - Python Version PyPI - Django Version made-with-python

Django Profanity Filter is a simple Django app that introduces a range of template tags and filters and model validators that remove or censor inappropriate language.

Installation

  1. Install via pip
$ pip install django-profanity-filter
  1. Add 'profanity', to your INSTALLED_APPS in settings.py
INSTALLED_APPS = (
...
'profanity',
...
)

Usage

Template Tags

At the top of every template you wish to use profanity filters and tags on, make sure to load the profanity tags.

...
{% load profanity %}
...
Censor Filter
Example
{% with string='You are a bitch!' %}
{{ string|censor }}
{% endwith %}

The output will be You are a *****!, instead of You are a bitch!.

Is Profane Tag
Example
{% with string='You are a bitch!' %}
{{ string|is_profane }}
{% endwith %}

The output will be True, since the string contains profanity.

Validators

Is Profane Validator
Example
from profanity.validators import validate_is_profane

class Post(models.Model):
    post = models.TextArea(max_length=150, validators=[validate_is_profane])

TODO

Template Tags

  • Basic filter
  • Advanced filter
    • Keyword argument for custom word filter

Validators

  • Basic Censorship Validator