skillfed

django-widget-tweaks

Tweak the form field rendering in templates, not in python-level form definitions.

django-widget-tweaks v1.5.1 1.6M downloads/30d#3,763 on PyPI2,163
Permissive license MIT license Active released

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-tweaks

uv

uv add django-widget-tweaks

poetry

poetry add django-widget-tweaks

Installing 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

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries :: Python Modules

Tags

django form field stylingtemplate form customizationdjango css class form fieldshtml attribute form tweaksdjango template form rendering
django-formstemplate-filters

More Python Modules packages

idna

Converts domain names between Unicode and…

permissive · top 100 on PyPI

setuptools

Setuptools is a Python build backend and…

permissive · top 100 on PyPI

PyYAML

PyYAML parses and emits YAML 1.1 data format,…

permissive · top 100 on PyPI

pydantic

Pydantic validates Python data structures…

permissive · top 100 on PyPI

annotated-types

Provides reusable metadata objects for use with…

permissive · top 100 on PyPI

typing-inspection

Provides runtime tools to inspect and…

permissive · top 100 on PyPI

django-tinymce

django-tinymce provides a Django form widget…

copyleft · top 5,000 on PyPI

crispy-tailwind

Provides Tailwind CSS styling templates for…

permissive · top 15,000 on PyPI

crispy-bootstrap4

Provides Bootstrap 4 HTML templates for…

permissive · top 15,000 on PyPI

django-json-widget

Provides a rich JSON editor widget for Django's…

permissive · top 5,000 on PyPI

django-bootstrap-form

Renders Django form fields as Bootstrap-styled…

permissive · top 15,000 on PyPI

django-js-asset

Adds script, stylesheet, and JSON tags with…

permissive · top 5,000 on PyPI

django-ace

Integrates the ACE code editor into Django…

permissive · top 15,000 on PyPI

django-debug-toolbar-template-profiler

Adds a debug panel to django-debug-toolbar that…

permissive · top 15,000 on PyPI

django-debug-toolbar-template-timings

A Django Debug Toolbar panel that measures and…

unclear · top 15,000 on PyPI

django-dirtyfields

Tracks which fields on a Django model instance…

permissive · top 15,000 on PyPI