Add sub filter
This is the opposite of the default `add` filter.
This commit is contained in:
1 parent
29c2d44704
commit
e284f760af
1 file changed
+11
@@ -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 ""
|
||||
|
||||
Reference in new issue
Block a user