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 deIntl.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
é umdict
com as informações do parâmetrooptions
deIntl.NumberFormat
.
-
Contribuindo com o projeto
(venv) poetry install
(venv) pytest
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file coral_decimal_mask-0.4.1.tar.gz
.
File metadata
- Download URL: coral_decimal_mask-0.4.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.1 Linux/6.4.15-200.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4488347b1d9d66f02e50708ec81ea928fc13c13bd775da1ac1f54219d27c802e |
|
MD5 | 791db34495f74505acf1a5d5f43c51c7 |
|
BLAKE2b-256 | 0446d526de4212f568d041c60300793769d653c01796590e12b12d309643512a |
File details
Details for the file coral_decimal_mask-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: coral_decimal_mask-0.4.1-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.1 Linux/6.4.15-200.fc38.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9fa89c2ea89c1760cc2f396f8ad3a90e6888762fc5d7fae0b7bc975372fae3e |
|
MD5 | 282968a542acfa2d700b6f9a292d7155 |
|
BLAKE2b-256 | 5c0b9bfdd12fed85f5c88f20446eb8b026fa119fb63658b1f68f76a532198388 |