Metadata-Version: 2.4
Name: django-formula-field
Version: 0.1.2
Summary: Django field for storing and evaluating formula expressions
Author-email: j0hn-mc-clane <you@example.com>
License: MIT
Project-URL: Homepage, https://github.com/j0hn-mc-clane/django-formulafield
Project-URL: Repository, https://github.com/j0hn-mc-clane/django-formulafield
Project-URL: Issues, https://github.com/j0hn-mc-clane/django-formulafield/issues
Keywords: django,field,formula,evaluation
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=4.2
Requires-Dist: formulas>=1.2
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-django; extra == "dev"
Requires-Dist: pylint; extra == "dev"
Requires-Dist: pyright; extra == "dev"
Dynamic: license-file

# Django Formula Field
When you want to provide placeholder columns for user to fill in based on values of the rows, you oftentimes want to have an Excel-like formula parser. This is the aim of this package, you provide a formula field and an evaluated result field.

## Installation

Installation through pip: `pip install django-formula-field`
## Getting Started

Defining an EvaluatedFormulaField is quite simple, you define a model:

```python
from django.db import models
from django_formulafield.fields import EvaluatedFormulaField

class SampleModel(models.Model):
    formula = models.CharField(max_length=255)
    result = EvaluatedFormulaField(formula_field="formula")  
```

Optional parameters are:
- max_length: behind the scenes, the evaluation is stored in a CharField
- reevaluate_on_update: if it should update the evaluation when you update the record

Formula field can be a callable function defined on the model.

## Evaluation
Evaluation is completely offloaded to the [formulas](https://pypi.org/project/formulas/) and any FormulaErrors are raised
