Skip to main content

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 git+https://github.com/blasferna/django-calculation.git#egg=django-calculation

Add calculation to your INSTALLED_APPS

INSTALLED_APPS = [
	...
	'calculation',
]

Usage

Import NumericCalculationInput from calculation.widgets and complete the calculation attribute like this.

from django import forms

from calculation.widgets import NumericCalculationInput

class TestForm(forms.Form):
    quantity = forms.DecimalField()
    price = forms.DecimalField()
    amount = forms.DecimalField(
        widget=NumericCalculationInput(
            attrs={
                'calculation': {
                    'mode': NumericCalculationInput.FORMULA,
                    'formula': 'quantity*price'
                }
            }
        )
    )

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-calculation-0.0.2.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

django_calculation-0.0.2-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

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