Add sub filter

This is the opposite of the default `add` filter.
This commit is contained in:
tcely authored and GitHub committed 2025-03-09 19:33:45 -04:00
1 parent 29c2d44704
commit e284f760af
1 file changed
+11
+11
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 ""