--- id: django-bleach version: "3.1.0" license: MIT license_treatment: permissive maintenance: abandoned --- # django-bleach — Easily use bleach with Django models and templates License: permissive · Maintenance: abandoned · Downloads: 105.8K/mo ## What it is and what it does django-bleach wraps bleach to make HTML sanitization a first-class feature in Django applications. It provides a BleachField model field that automatically sanitizes HTML before saving to the database, a corresponding form field for user input, and template filters for rendering untrusted content safely. The package lets you define allowed HTML tags, attributes, and CSS styles through Django settings, then applies those rules consistently across your application. The core problem it solves is preventing XSS attacks and malformed HTML when accepting user-generated content. Instead of storing raw HTML or stripping all markup, django-bleach preserves semantic tags while removing script tags, event handlers, and other dangerous constructs. It integrates directly into Django's ORM and form layer, so sanitization happens automatically without extra middleware or view-level logic. Use it for: - Blog or CMS platforms where users write posts with basic formatting but you need to prevent script injection - Comment systems that allow limited HTML markup while blocking malicious content - User profile descriptions or bio fields that should support simple rich text - Converting URL-like strings to links in user-submitted text using the bleach_linkify filter - Rendering third-party or legacy HTML content in templates without exposing your application to embedded attacks ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Integrates bleach HTML sanitization into Django models, forms, and templates to strip unsafe HTML tags and attributes from user input while preserving safe markup. No. The repository is archived and abandoned with no maintenance since 2023-08-05. While the code is stable and currently compatible with Django 3.2–4.2, there is no path forward for security patches, Django 5.0+ support, or bleach library updates. For new projects, use an actively maintained alternative or apply bleach directly in your views. For existing projects still on supported Django versions, it remains functional but carries increasing technical debt. ## Install pip install django-bleach uv add django-bleach poetry add django-bleach ## Installing django-bleach Before you install: Low install friction with a pure-Python wheel. However, the repository is archived and abandoned as of 1105 days since last release, with the latest version from 2023-08-05. No active maintenance means security updates are unlikely. License in practice: MIT license is permissive and imposes no restrictions on use, modification, or distribution in commercial or private projects. Quickstart: pip install django-bleach # In settings.py INSTALLED_APPS = ['django_bleach'] BLEACH_ALLOWED_TAGS = ['p', 'b', 'i', 'u', 'em', 'strong', 'a'] # In models.py from django_bleach.models import BleachField class Post(models.Model): content = BleachField() Verify before relying: - Whether bleach itself receives active security updates and how that affects django-bleach's viability - Compatibility with Django versions beyond 4.2 given the abandoned status - Real-world performance impact of sanitization on high-volume user input ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: abandoned - Downloads: 105.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django html sanitization, bleach integration django, user html input cleaning, xss prevention django, safe html rendering django, html tag filtering, django content sanitizer, html-sanitization, security, abandoned [View on SkillFed](https://skillfed.io/packages/django-bleach) · [View on PyPI](https://pypi.org/project/django-bleach/)