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_attrssão algumas opções para construir o objeto javascript Intl.NumberFormat.-
localesé o primeiro parâmetro deIntl.NumberFormatreferente 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é umdictcom as informações do parâmetrooptionsdeIntl.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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b516630283c731bcbc60b94ee871174ef150c4e65a0fe56e56fb38c83e76422
|
|
| MD5 |
ecf1888714949afeac0bee0faecaee27
|
|
| BLAKE2b-256 |
b17a193dd30bdcf9190d65b376650693c007c9ad83cd4e8870cb2da664f7f1f8
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7446b59d68e3909312181d60acc773df8a883c44508ccc97eec308c32b03d295
|
|
| MD5 |
bac2b2f6508dddd39365ba9c3ea8ae37
|
|
| BLAKE2b-256 |
201bd65a03a0710a57fff505f792fdcf18eb3ce3abf20b91066e8232340e63d5
|