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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bb8faa68dcb18ae12a524faff83e78cd76934e7c2758663768afd8c43a6034c
|
|
| MD5 |
4e1f7049509f4b0b909ed9a51abc49b2
|
|
| BLAKE2b-256 |
e4185b296e0dc6d3f6416fff20f4962c8e68ed123e934bbc9811e3a30a981fcc
|
Provenance
The following attestation bundles were made for django_clearable_widget-1.1.0.tar.gz:
Publisher:
release.yml on bashu/django-clearable-widget
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_clearable_widget-1.1.0.tar.gz -
Subject digest:
1bb8faa68dcb18ae12a524faff83e78cd76934e7c2758663768afd8c43a6034c - Sigstore transparency entry: 2466211708
- Sigstore integration time:
-
Permalink:
bashu/django-clearable-widget@c899dfb1655ad740b2725e7486ecf8fb042164ab -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/bashu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c899dfb1655ad740b2725e7486ecf8fb042164ab -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_clearable_widget-1.1.0-py3-none-any.whl.
File metadata
- Download URL: django_clearable_widget-1.1.0-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90835d5768d36848a5fcc39c9bdd9b1c7de190e3ef9953f44b666167f7ddeb0f
|
|
| MD5 |
0980d505573b5a5fa8022867bc217790
|
|
| BLAKE2b-256 |
95b0921d8e83afbfb90b899b6f5a8d110dd27b75ace3990a3539427461778813
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_clearable_widget-1.1.0-py3-none-any.whl -
Subject digest:
90835d5768d36848a5fcc39c9bdd9b1c7de190e3ef9953f44b666167f7ddeb0f - Sigstore transparency entry: 2466211795
- Sigstore integration time:
-
Permalink:
bashu/django-clearable-widget@c899dfb1655ad740b2725e7486ecf8fb042164ab -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/bashu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c899dfb1655ad740b2725e7486ecf8fb042164ab -
Trigger Event:
push
-
Statement type: