Skip to main content

Custom widget that limits the number of characters that can be entered in a textarea field

Project description

django-charsleft-widget is a custom widget that limits the number of characters that can be entered in a textarea field.

Authored by Basil Shubin

https://img.shields.io/pypi/v/django-charsleft-widget.svg https://img.shields.io/pypi/dm/django-charsleft-widget.svg https://img.shields.io/github/license/bashu/django-charsleft-widget.svg https://img.shields.io/travis/bashu/django-charsleft-widget.svg https://raw.githubusercontent.com/bashu/django-charsleft-widget/develop/showcase.gif

Installation

pip install django-charsleft-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 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 only Django 1.4 or above to run that. It might run on older versions but that is not tested.

License

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

Project details


Download files

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

Source Distribution

django-charsleft-widget-0.1.9.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

django_charsleft_widget-0.1.9-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file django-charsleft-widget-0.1.9.tar.gz.

File metadata

  • Download URL: django-charsleft-widget-0.1.9.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for django-charsleft-widget-0.1.9.tar.gz
Algorithm Hash digest
SHA256 561a1f8496004c3b71bd5deb7a6975f1a44b6dd819d0557d15d82a1b33fae0c1
MD5 f77020c222bc36b92375679ee8b4b6c7
BLAKE2b-256 2846707aedaa693ac8e231e0a61ae2d8dab916b62492c5837b892cc49e99f340

See more details on using hashes here.

File details

Details for the file django_charsleft_widget-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: django_charsleft_widget-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for django_charsleft_widget-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 596e46caa94dbdce831966ee541a1742c8d1cd4e89b0ad17aeb61bca8335d136
MD5 0754a00d92fc02e7d9f27c387f4d25ac
BLAKE2b-256 348ff1eabf4f289a436c4859ddbe0d4f8eb6074051b1a83bd7fd06f2b9a46e0f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page