A Django app to make simple calculations in your django forms
Project description
django-calculation
Make simple calculations in your django forms.
Installation
pip install django-calculation
Add calculation
to your INSTALLED_APPS
INSTALLED_APPS = [
...
'calculation',
]
Usage
Import calculation
and complete the definition like this. The widget NumericCalculationInput
expects the calculation definition as the first argument.
from django import forms
import calculation
class TestForm(forms.Form):
quantity = forms.DecimalField()
price = forms.DecimalField()
amount = forms.DecimalField(
widget=calculation.NumericCalculationInput(
{
'mode': calculation.FORMULA,
'formula': 'quantity*price'
},
attrs = {'disabled': True}
)
)
tax = forms.DecimalField(
widget=calculation.NumericCalculationInput(
{
'mode': calculation.FORMULA,
'formula': 'parseFloat(amount/11).toFixed(2)'
},
attrs = {'disabled': True}
)
)
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
Built Distribution
Close
Hashes for django_calculation-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d886a84c925943c52fec12dd27c79413b1120249c2c4c235ec72156b0b7df403 |
|
MD5 | c35de08719b25dbc08ba770799b86bd5 |
|
BLAKE2b-256 | 21958890ea72460e07804de285c462ffb659a1e8ebc2e71a10aea482605f3d8e |