django-widget-tweaks
Tweak the form field rendering in templates, not in python-level form definitions.
What it is and what it does
django-widget-tweaks is a template library that lets designers and front-end developers customize how Django form fields render in HTML without writing Python code. It provides template tags and filters to add or modify CSS classes, HTML attributes, and data attributes on form fields directly in templates.
The package offers two main interfaces: a `render_field` tag with HTML-like syntax for straightforward customization, and a set of filters (`add_class`, `attr`, `set_data`, `add_error_class`, etc.) for more granular control. It handles single and multi-widget fields, supports filter chaining with leftmost-wins semantics for reusable templates, and integrates cleanly with Django's form rendering pipeline.
Use it for:
- Add CSS classes to form fields for styling without touching Python form code.
- Set HTML5 data attributes on fields for unobtrusive JavaScript hooks.
- Apply error or required-field styling conditionally based on validation state.
- Convert input types to HTML5 variants (e.g., text to search) in templates.
- Build reusable field templates with overridable default attributes.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Customize Django form field HTML and CSS in templates using template tags and filters, without modifying Python form definitions.
Yes. It is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and solves a real workflow problem—separating form presentation from Python logic. Install if your Django project has designers or front-end developers who need to customize form rendering without Python changes.
Install
django-widget-tweaks on PyPI
pip
pip install django-widget-tweaksuv
uv add django-widget-tweakspoetry
poetry add django-widget-tweaksInstalling django-widget-tweaks
Before you install
Low friction: pure Python wheel with only django as a runtime dependency. Active maintenance—last commit 2026-06-29, 2163 repository stars, and a release within the last year.
License in practice
MIT license (permissive). No restrictions on commercial or private use; you may modify and redistribute with attribution.
Quickstart
# Install
pip install django-widget-tweaks
# Add to INSTALLED_APPS in settings.py
INSTALLED_APPS += ['widget_tweaks']
# In template
{% load widget_tweaks %}
{{ form.title|add_class:"css_class_1 css_class_2" }}
{% render_field form.search_query type="search" %}
Package facts
| License | MIT license (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — django |
| Maintenance | actively maintained — 224 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,559,231/month — #3,763 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_widget_tweaks-1.5.1-py3-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
django-tinymcedjango-tinymce provides a Django form widget…
copyleft · top 5,000 on PyPI
crispy-tailwindProvides Tailwind CSS styling templates for…
permissive · top 15,000 on PyPI
crispy-bootstrap4Provides Bootstrap 4 HTML templates for…
permissive · top 15,000 on PyPI
django-json-widgetProvides a rich JSON editor widget for Django's…
permissive · top 5,000 on PyPI
django-bootstrap-formRenders Django form fields as Bootstrap-styled…
permissive · top 15,000 on PyPI
django-js-assetAdds script, stylesheet, and JSON tags with…
permissive · top 5,000 on PyPI
django-aceIntegrates the ACE code editor into Django…
permissive · top 15,000 on PyPI
django-debug-toolbar-template-profilerAdds a debug panel to django-debug-toolbar that…
permissive · top 15,000 on PyPI
django-debug-toolbar-template-timingsA Django Debug Toolbar panel that measures and…
unclear · top 15,000 on PyPI
django-dirtyfieldsTracks which fields on a Django model instance…
permissive · top 15,000 on PyPI