django-mathfilters
Introduction
django-mathfilters is a pip-installable Python 2/3 module that provides different simple math filters for Django.
Django provides an add
template filter, but no corresponding subtracting, multiplying or dividing filters.
Django ticket #361 has been closed as wontfix, so I had to create an alternative that is easy to install in a new Django project.
Installation
pip install django-mathfilters
Usage
Add
mathfilters
toINSTALLED_APPS
INSTALLED_APPS += ('mathfilters', )
You need to load
mathfilters
at the top of your template. The script provides the following filters:sub
– subtractionmul
– multiplicationdiv
– divisionintdiv
– integer (floor) divisionabs
– absolute valuemod
– moduloaddition
– replacement for theadd
filter with support for float / decimal types
References
[1] django-mathfilters@Github, django-mathfilters — provides a set of simple math filters for Django