{"id":37071893,"url":"https://github.com/blasferna/django-calculation","last_synced_at":"2026-01-14T08:26:32.450Z","repository":{"id":40408963,"uuid":"394686310","full_name":"blasferna/django-calculation","owner":"blasferna","description":"Make simple calculations in your django forms.","archived":false,"fork":false,"pushed_at":"2022-06-07T17:25:24.000Z","size":48,"stargazers_count":21,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-27T17:22:25.416Z","etag":null,"topics":["django","django-formsets","django-widget","javascript","python"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blasferna.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-10T14:33:38.000Z","updated_at":"2025-08-22T23:46:00.000Z","dependencies_parsed_at":"2022-08-09T19:31:21.084Z","dependency_job_id":null,"html_url":"https://github.com/blasferna/django-calculation","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/blasferna/django-calculation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blasferna%2Fdjango-calculation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blasferna%2Fdjango-calculation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blasferna%2Fdjango-calculation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blasferna%2Fdjango-calculation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blasferna","download_url":"https://codeload.github.com/blasferna/django-calculation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blasferna%2Fdjango-calculation/sbom","scorecard":{"id":242845,"data":{"date":"2025-08-11","repo":{"name":"github.com/blasferna/django-calculation","commit":"8739eefdf125c9585f7bf18ef79fb1b3b8f7067e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/blasferna/django-calculation/release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/blasferna/django-calculation/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/blasferna/django-calculation/release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/blasferna/django-calculation/release.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/release.yml:26","Warn: pipCommand not pinned by hash: .github/workflows/release.yml:27","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-17T06:57:30.120Z","repository_id":40408963,"created_at":"2025-08-17T06:57:30.120Z","updated_at":"2025-08-17T06:57:30.120Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:16:59.381Z","status":"ssl_error","status_checked_at":"2026-01-14T08:13:45.490Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-formsets","django-widget","javascript","python"],"created_at":"2026-01-14T08:26:31.766Z","updated_at":"2026-01-14T08:26:32.442Z","avatar_url":"https://github.com/blasferna.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-calculation\n\n[![Release](https://github.com/blasferna/django-calculation/actions/workflows/release.yml/badge.svg)](https://github.com/blasferna/django-calculation/actions/workflows/release.yml)\n[![PyPI version](https://img.shields.io/pypi/v/django-calculation.svg?color=success)](https://pypi.python.org/pypi/django-calculation)\n![PyPI - Django Version](https://img.shields.io/pypi/djversions/django-calculation) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-calculation)\n\nMake simple calculations in your django forms using `django-calculation`. This app provide a **[Django Widget](https://docs.djangoproject.com/en/3.2/ref/forms/widgets/)** that derives its value from a expression defined in the widget instance. \n\nThe field is updated when any of the source fields change.\n\n![calculation](https://user-images.githubusercontent.com/8385910/142947517-49a5d6a0-6a6c-41d6-8f14-a140ad44fa1e.gif)\n\n\n\n## Installation\n\n```bash\npip install django-calculation\n```\n\n### Add `calculation` to your INSTALLED_APPS\n\n```python\nINSTALLED_APPS = [\n    ...\n    'calculation',\n]\n````\n\n\n## Usage\n\nImport `calculation` and complete the definition. \n\n### Example\n\nUsing `FormulaInput` widget\n\n```python\nfrom django import forms\n\nimport calculation\n\n\nclass TestForm(forms.Form):\n    quantity = forms.DecimalField()\n    price = forms.DecimalField()\n    amount = forms.DecimalField(\n        widget=calculation.FormulaInput('quantity*price') # \u003c- using single math expression\n    )\n    apply_taxes = forms.BooleanField(initial=True)\n    tax = forms.DecimalField(\n        # using math expression and javascript functions.\n        widget=calculation.FormulaInput('apply_taxes ? parseFloat(amount/11).toFixed(2) : 0.0') \n    )\n\n```\n\n`django-calculation` works with static files and therefore it is necessary to include the media of the form in the template file.\n\n```html\n\u003cform method=\"post\"\u003e\n    {% csrf_token %}\n    {{ form }}\n    \u003cinput type=\"submit\" value=\"Submit\"\u003e\n\u003c/form\u003e\n\n{{ form.media }}\n```\n\n### Modes\n\nCurrently the app support two modes of calculation `FORMULA` and `SUMMARY`.\n\n***`FORMULA`*** \n\nThe field value derive from a formula expression. In the expression you can refer to the form field using its name.\n\n```python\namount = forms.DecimalField(\n    widget=calculation.FormulaInput('quantity*price')\n)\n```\n\n***`SUMMARY`*** \n\nThe field value derive from a summary definition, it is useful when you need to get the sum of a django formset field.\n\n```python\ntotal = forms.DecimalField(\n    widget=calculation.SummaryInput(\n            function=calculation.SUM,\n            field='amount' \n    )\n```\n\n#### Summary example\n\nSummary definition in `OrderForm`\n\n```python\nclass OrderForm(forms.ModelForm):\n    total = forms.DecimalField(\n        # using SumInput a SummaryInput abstraction\n        widget=calculation.SumInput('subtotal')\n    )\n    class Meta:\n        model = Order\n        fields = ['date', 'customer']\n```\n\n`OrderDetForm` also contain a calculated field `subtotal`.\n```python\nclass OrderDetForm(forms.ModelForm):\n    subtotal = forms.DecimalField(\n        widget=calculation.FormulaInput('quantity*price')\n    )\n    class Meta:\n        model = OrderDet\n        fields = ['product', 'price', 'quantity', 'subtotal']\n\n# formset definition\nOrderDetFormSet = forms.inlineformset_factory(Order, OrderDet, OrderDetForm)\n```\n\n![chrome-capture](https://user-images.githubusercontent.com/8385910/129214716-e3876719-1912-49b0-989f-125e724dfb92.gif)\n\n\n## Roadmap\n\n- Create demo project.\n- Create documentation.\n- \u003cdel\u003e Add changelog. \u003c/del\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblasferna%2Fdjango-calculation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblasferna%2Fdjango-calculation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblasferna%2Fdjango-calculation/lists"}