How blasferna/django-calculation works
Project type and purpose
• This is a reusable Django app (“django-calculation”) that augments Django forms with client-side calculated fields.
• It delivers two widget types (FormulaInput and SummaryInput) that derive their values via a JavaScript expression or aggregation when source fields change.
File structure
• Top-level files:
– README.md, LICENSE, CHANGELOG.md, MANIFEST.in, setup.py (packaging & metadata)
– .github/workflows/release.yml (CI/CD pipeline)
• calculation/ (the Django app):
– __init__.py, apps.py (Django app registration)
– widgets.py (widget classes: FormulaInput, SummaryInput, SumInput helper)
– static/calculation/js/calculation.js (front-end logic to parse expressions and update fields)
Insights from README
• Explains installation (pip + add to INSTALLED_APPS), usage within Django forms, two modes (FORMULA, SUMMARY), and the need to include form.media for static assets.
• No database models—primary functionality lives in form widgets and client-side JS.