Skip to main content
https://badge.fury.io/py/django-clearable-widget.svg https://img.shields.io/pypi/pyversions/django-clearable-widget.svg https://img.shields.io/pypi/djversions/django-clearable-widget.svg https://github.com/bashu/django-clearable-widget/actions/workflows/test.yml/badge.svg

django-clearable-widget is a custom widget that adds a input clearing button on any input fields that are using it. It clears the value, and returns focus to that field.

https://raw.githubusercontent.com/bashu/django-clearable-widget/develop/showcase.gif

Installation

pip install django-clearable-widget

Setup

Add clearable_widget to INSTALLED_APPS:

INSTALLED_APPS += (
    'clearable_widget',
)

and just include clearable_widget templates

{% include "clearable_widget/clearable_widget_css.html" %} {# Before the closing head tag #}
{% include "clearable_widget/clearable_widget_js.html" %} {# Before the closing body tag #}

When deploying on production server, don’t forget to run:

python manage.py collectstatic

Usage

All you need now is to import ClearableInput class and override field’s widget, for example:

from clearable_widget import ClearableInput

class Form(forms.Form):

    field = forms.CharField(widget=ClearableInput)

Please see example application. This application is used to manually test the functionalities of this package. This also serves as a good example.

You need only Django 1.4 or above to run that. It might run on older versions but that is not tested.

License

django-clearable-widget is released under the BSD license.

Changes

1.2.0 (2026-09-08)

  • Dropped the jQuery dependency; clearable.js is now plain vanilla JS.

1.1.0 (2026-08-14)

  • Dropped Python <3.10 / Django <5.2 support; added Django 6.0 / 6.1 support.

  • Moved the Jinja2 template into clearable_widget/jinja2/ so it’s genuinely served by the Jinja2 backend instead of silently falling through to DjangoTemplates.

  • Fixed the clear button staying hidden on pre-filled fields until the first keystroke.

  • Fixed a dead if (form) check in clearable.js that never actually guarded anything.

1.0.0 (2021-11-30)

  • Added Django 3+ support.

  • Dropped Python 2.7 support.

  • Dropped Django 1.10 / 1.11 support.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_clearable_widget-1.2.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_clearable_widget-1.2.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file django_clearable_widget-1.2.0.tar.gz.

File metadata

  • Download URL: django_clearable_widget-1.2.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for django_clearable_widget-1.2.0.tar.gz
Algorithm Hash digest
SHA256 be11d23eb38274a5a949b4920618a7c22f9a705f602648bf6e0a4c4c660bd051
MD5 afc340daae17ab554314f1d0035dc0ab
BLAKE2b-256 1691e0233543b2d29b3bde58300779eedbeca11704332f7ce677c432a475e55d

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_clearable_widget-1.2.0.tar.gz:

Publisher: release.yml on bashu/django-clearable-widget

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_clearable_widget-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_clearable_widget-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeeab53e88bf47eb824b53955e20643de939ff97216dbc09f22714427afe737b
MD5 b23bd6f1910c6c86f567705babc115ba
BLAKE2b-256 c557fbde191017a73f059b4f52d37da76617b72335dced67edb3abe2f011e292

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_clearable_widget-1.2.0-py3-none-any.whl:

Publisher: release.yml on bashu/django-clearable-widget

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 files

1.1.0

2 files

1.0.0

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

1 file

0.1.3

1 file

0.1.2

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page