django-mathfilters
A set of simple math filters for Django
What it is and what it does
django-mathfilters extends Django's template language with arithmetic filters for use in templates. Django provides an `add` filter but omits subtraction, multiplication, division, and other basic math operations; this package fills that gap by offering `sub`, `mul`, `div`, `intdiv`, `abs`, `mod`, and an enhanced `addition` filter that handles float and Decimal types in addition to integers.
The package is a simple, zero-dependency Django app that you install via pip and register in INSTALLED_APPS. Once loaded in a template with `{% load mathfilters %}`, you can apply arithmetic operations inline—for example, `{{ 13|sub:17 }}` or `{{ answer|mul:0.5 }}`—without writing custom template tags or view logic.
Use it for:
- Display calculated values in Django templates without writing custom template tags—e.g., show discounted prices or percentage calculations.
- Perform simple arithmetic on template variables for display purposes, such as dividing totals by counts to show averages.
- Handle float and Decimal arithmetic in templates where Django's built-in `add` filter would not suffice.
- Reduce boilerplate by avoiding custom template tag definitions for straightforward math operations.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Django template filters for basic arithmetic operations—subtraction, multiplication, division, modulo, and absolute value—that Django's built-in template system does not include.
Yes, if you are on Django 1.11–3.x with Python 3.5–3.7 and need simple math filters in templates. No, if you are using modern Django or Python versions—the package is abandoned and has not been updated since 2020, so compatibility with current releases is uncertain. Consider writing a custom template tag or moving calculations to your view layer if you need active maintenance.
Install
django-mathfilters on PyPI
pip
pip install django-mathfiltersuv
uv add django-mathfilterspoetry
poetry add django-mathfiltersInstalling django-mathfilters
Before you install
Installation is straightforward with no runtime dependencies. However, the package is abandoned—last commit was 2020-10-13 and no releases since 2020-02-10—so it will not receive bug fixes or updates for modern Django or Python versions.
License in practice
MIT License is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install django-mathfilters
Then add 'mathfilters' to INSTALLED_APPS in settings.py.
In a template:
{% load mathfilters %}
{{ 13|sub:17 }}
{{ 42|mul:0.5 }}
{{ 12|div:3 }}
Requires Django to be installed and configured; the package itself has no runtime dependencies but is a Django app extension.
Verify before relying
- Whether the package works with Django versions released after 2020 without issues.
- Current compatibility with Python 3.8+ given the last release predates those versions.
- Whether float/Decimal arithmetic in filters handles edge cases (NaN, infinity, precision loss).
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,377 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 636,814/month — #5,621 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_mathfilters-1.0.0-py3-none-any.whl
Keywords: django, template, filters, math
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
py-moneyRepresents monetary amounts with currency-aware…
permissive · top 15,000 on PyPI
django-more-admin-filtersProvides a collection of Django admin filter…
permissive · top 15,000 on PyPI
django-markdownifyA Django template filter that converts Markdown…
permissive · top 15,000 on PyPI
django-filterDjango-filter adds dynamic QuerySet filtering…
permissive · top 5,000 on PyPI
bitmathbitmath converts and performs arithmetic on…
permissive · top 15,000 on PyPI
lighteccLightECC provides elliptic curve arithmetic…
permissive · top 15,000 on PyPI
django-typerBuilds type-safe Django management command CLIs…
permissive · top 15,000 on PyPI
latex2sympy2Parses LaTeX math expressions and converts them…
permissive · top 15,000 on PyPI
django-widget-tweaksCustomize Django form field HTML and CSS in…
permissive · top 5,000 on PyPI
django-admin-rangefilterAdds date range, datetime range, and numeric…
permissive · top 5,000 on PyPI