django-charsleft-widget
django-charsleft-widget is a custom widget that limits the number of characters that can be entered in a textarea field.
Installation
pip install django-charsleft-widget
Setup
Add charsleft_widget to INSTALLED_APPS:
INSTALLED_APPS += (
'charsleft_widget',
)
and just include charsleft_widget templates
{% include "charsleft_widget/charsleft_widget_css.html" %} {# Before the closing head tag #}
{% include "charsleft_widget/charsleft_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 django.forms.fields import CharField
from charsleft_widget import CharsLeftArea
class Form(forms.Form):
field = CharField(max_length=128, widget=CharsLeftArea)
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 Django 5.2 or above to run that.
License
django-charsleft-widget is released under the BSD license.
Changes
1.3.0 (2026-10-10)
Dropped Python 3.10 support; Python 3.11 is now the minimum supported version.
1.2.0 (2026-09-08)
Dropped the jQuery dependency: charsleft.js is now plain JavaScript with no reliance on window.jQuery or window.django.jQuery. Pages that inject markup after page load (formsets, ajax) now re-bind newly-added .charsleft widgets via window.charsleft(scope) instead of the former $.fn.charsleft jQuery plugin.
1.1.0 (2026-08-14)
Added Django 6.0 and 6.1 support, alongside existing Django 5.2 support (fixes #7).
Dropped Python < 3.10 support.
Fixed charsleft.js: a page without both jQuery and a django global crashed with ReferenceError: django is not defined; typing past maxlength right on an emoji or other astral character split its UTF-16 surrogate pair and corrupted the field; only keyup/change were handled, so paste-via-mouse and IME input didn’t update the count; dynamically-added widgets (formsets, ajax) were never wired up; and the charsleft helper leaked onto window.
Fixed USE_JINJA rendering: textarea.jinja lived under templates/, where Django’s Jinja2 backend (APP_DIRS scans each app’s jinja2/ directory) could never find it; moved it to charsleft_widget/jinja2/.
Removed charsleft_widget/fields.py, a pre-Django-1.7 maxlength shim superseded by Django core and unused since.
locale/ and jinja2/ assets weren’t declared in package-data and were silently missing from built wheels/sdists; added.
Increased test coverage to 100%; added tests for Media, a value already over maxlength, and the Jinja2 backend actually being used.
Reformatted code and templates, and fixed ruff lint findings.
1.0.0 (2021-11-30)
Added Django 3+ support.
Dropped Python 2.7 support.
Dropped Django 1.10 / 1.11 support.
Metadata
Release files for django-charsleft-widget 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_charsleft_widget-1.3.0.tar.gz | 11.6 kB | With provenance | Details for django_charsleft_widget-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_charsleft_widget-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for django_charsleft_widget-1.3.0-py3-none-any.whl |
Total release size: 22.5 kB
Release files / django_charsleft_widget-1.3.0.tar.gz
| Download URL | django_charsleft_widget-1.3.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66bbf52f8392b9910d8fa494e3702c2972ec4ed4e70eb37989686cff570949be
|
|
BLAKE2b-256 checksum How to use checksums |
05c3f3fcc78ccac88eb8454a6e4e86000eb9f274f46ce0e50573b24c4d2137cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logRelease files / django_charsleft_widget-1.3.0-py3-none-any.whl
| Download URL | django_charsleft_widget-1.3.0-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29c535e5a4cbd961cd6bc1d8d40b17b1b4044969af148d5fc2e4ee534ea4e273
|
|
BLAKE2b-256 checksum How to use checksums |
8838aca60e2d5f5f4291653e32e0b4f0df3523066c4a5677046963c65d5c1601
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logSecurity for django-charsleft-widget 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for django_charsleft_widget-1.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.