Skip to main content

JavaScript input masks for Django

Project description

Django Input Mask

A collection of easy-to-extend-widgets for applying masks to input elements.

MIT licensed

Compatibility

  • Django 1.3, 1.4 and 1.5

  • Python 2.6, 2.7 and 3

Requirements

  • jQuery 1.8 or higher

We do not include jQuery in this package, you must add it by your hands.

Note: jQuery 1.9 support will be granted through the jQuery Migrate Plugin.

Just take a look on example_project/templates/form.html file for an example.

Installation

pip install django-input-mask

Or install directly from master branch:

pip install git+http://github.com/caioariede/django-input-mask.git#egg=input_mask

Or manually place it on your PYTHON_PATH.

Configuration

Add input_mask to the INSTALLED_APPS setting.

This is needed so that Django can handle the app’s static files

Usage

from django import forms
from django.contrib.localflavor.br.forms import BRPhoneNumberField

from input_mask.contrib.localflavor.br.widgets import BRPhoneNumberInput

class YourForm(forms.ModelForm):
    phone = BRPhoneNumberField(widget=BRPhoneNumberInput)

Decimal masks

from input_mask.fields import DecimalField

class MyForm(forms.ModelForm):
    my_decimal_field = DecimalField(max_digits=10, decimal_places=2)
  • input_mask.fields.DecimalField will automatically handle separators.

  • input_mask.contrib.localflavor.*.fields.*DecimalField will use local-based separators.

Creating your own masks

from input_mask.widgets import InputMask

class MyCustomInput(InputMask):
    mask = {'mask': '999-111'}

For more rules, take a look at meioMask documentation.

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-input-mask-1.3.6.tar.gz (10.1 kB view details)

Uploaded Source

File details

Details for the file django-input-mask-1.3.6.tar.gz.

File metadata

File hashes

Hashes for django-input-mask-1.3.6.tar.gz
Algorithm Hash digest
SHA256 2d6906afb5841b1bc5f9c135d7dde0733539945a98e99c53a9c40587884a3235
MD5 a9da1460a4fc0c8dbfe0f23d6476ee47
BLAKE2b-256 b86206598ae9a525a4e17776582c9edc24c94f3a444518dc19a2aeda3046c971

See more details on using hashes here.

Supported by

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