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

External dependencies

  • jQuery - this is not included in the package since it is expected that in most scenarios this would already be available.

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.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.1.0.tar.gz (10.2 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.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_clearable_widget-1.1.0.tar.gz
  • Upload date:
  • Size: 10.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 1bb8faa68dcb18ae12a524faff83e78cd76934e7c2758663768afd8c43a6034c
MD5 4e1f7049509f4b0b909ed9a51abc49b2
BLAKE2b-256 e4185b296e0dc6d3f6416fff20f4962c8e68ed123e934bbc9811e3a30a981fcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_clearable_widget-1.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_clearable_widget-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90835d5768d36848a5fcc39c9bdd9b1c7de190e3ef9953f44b666167f7ddeb0f
MD5 0980d505573b5a5fa8022867bc217790
BLAKE2b-256 95b0921d8e83afbfb90b899b6f5a8d110dd27b75ace3990a3539427461778813

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_clearable_widget-1.1.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

1.2.0

2 files

This release

1.1.0 This release

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