Add sub filter

This is the opposite of the default `add` filter.
This commit is contained in:
tcely 2025-03-09 19:33:45 -04:00 committed by GitHub
parent 29c2d44704
commit e284f760af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,3 +12,14 @@ def bytesformat(input):
return output
return output[: -1 ] + 'iB'
@register.filter(is_safe=False)
def sub(value, arg):
"""Subtract the arg from the value."""
try:
return int(value) - int(arg)
except (ValueError, TypeError):
try:
return value - arg
except Exception:
return ""