Skip to main content

Django mask decimal fields

Project description

Coral Decimal Mask

Widgets que aplicam mascaras nos forms do django.

Instalação

python -m pip install coral-decimal-mask

Como usar

Adicione decimal_mask em INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "decimal_mask",
]

Configure seus widgets:

from django import forms
from decimal_mask.widgets import DecimalMaskWidget, MoneyMaskWidget, PercentMaskWidget


class MyForm(forms.Form):
    value1 = forms.DecimalField(widget=DecimalMaskWidget())
    value2 = forms.DecimalField(
        widget=DecimalMaskWidget(
            decimal_attrs={
                "locales": "pt-BR",
                "decimalPlaces": 2,
                "format": {
                    "style": "currency",
                    "currency": "BRL",
                },
            },
        ),
    ) # ou usar forms.DecimalField(widget=MoneyMaskWidget())
    value3 = forms.DecimalField(widget=PercentMaskWidget())
  • O parâmetro decimal_attrs são algumas opções para construir o objeto javascript Intl.NumberFormat.

    • locales é o primeiro parâmetro de Intl.NumberFormat referente a linguagem utilizada na interface do usuário da sua aplicação.

    • decimalPlaces é o número de casas decimais que a mascara vai considerar.

    • format é um dict com as informações do parâmetro options de Intl.NumberFormat.

Contribuindo com o projeto

(venv) poetry install
(venv) pytest

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

coral-decimal-mask-0.2.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coral_decimal_mask-0.2.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file coral-decimal-mask-0.2.2.tar.gz.

File metadata

  • Download URL: coral-decimal-mask-0.2.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.15.74-3-MANJARO

File hashes

Hashes for coral-decimal-mask-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1b516630283c731bcbc60b94ee871174ef150c4e65a0fe56e56fb38c83e76422
MD5 ecf1888714949afeac0bee0faecaee27
BLAKE2b-256 b17a193dd30bdcf9190d65b376650693c007c9ad83cd4e8870cb2da664f7f1f8

See more details on using hashes here.

File details

Details for the file coral_decimal_mask-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: coral_decimal_mask-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.7 Linux/5.15.74-3-MANJARO

File hashes

Hashes for coral_decimal_mask-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7446b59d68e3909312181d60acc773df8a883c44508ccc97eec308c32b03d295
MD5 bac2b2f6508dddd39365ba9c3ea8ae37
BLAKE2b-256 201bd65a03a0710a57fff505f792fdcf18eb3ce3abf20b91066e8232340e63d5

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