skillfed

django-mathfilters

A set of simple math filters for Django

django-mathfilters v1.0.0 636.8K downloads/30d#5,621 on PyPI169
Permissive license MIT Abandoned released

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-mathfilters

uv

uv add django-mathfilters

poetry

poetry add django-mathfilters

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.3Programming Language :: Python :: 3.4Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Internet :: WWW/HTTPTopic :: Software Development :: Libraries :: Python Modules

Tags

django template math filtersdjango arithmetic template filtersdjango subtraction multiplication division filtersdjango template calculatordjango math operations templates
django-template-filterstemplate-math

More Python Modules packages