django-mathfilters is a Python 3 module that provides a set of simple mathematical template filters for Django. It extends Django's built-in 'add' filter by offering operations like subtraction, multiplication, division, integer division, absolute value, and modulo. It supports 'int', 'float', and 'Decimal' types, allowing for basic arithmetic directly within templates. The current version is 1.0.0, and it serves as a stable utility for common math operations not natively supported by Django's template language.
pip install django-mathfiltersVerified import paths — ran on the pinned version, not inferred.
After installing the package, add 'mathfilters' to your `INSTALLED_APPS` in your Django project's `settings.py`. Then, in any Django template where you want to use the math filters, add `{% load mathfilters %}` at the top. You can then apply the filters to variables or literal values. Ensure values are numeric (int, float, Decimal) for correct operation.
Upgrade django-mathfilters to version 0.4.0 or higher. The current version 1.0.0 includes the 'addition' filter with float/decimal support.
Ensure that the variables or literals used with mathfilters are always of a numeric type. Perform type conversions in your Django views or models if necessary before passing data to the template.
Ensure `'mathfilters'` is present in your `INSTALLED_APPS` list in `settings.py`: `INSTALLED_APPS = ['...', 'mathfilters', ...]`.
No dependency data recorded yet.