Add: template tag for size_to_human_readable
This commit is contained in:
parent
cc104c1292
commit
846b029f70
1 changed files with 18 additions and 0 deletions
18
archivist/apps/sites/templatetags/string_helper.py
Normal file
18
archivist/apps/sites/templatetags/string_helper.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
from utils.strings import convert_size
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def size_to_human_readable (size):
|
||||||
|
"""
|
||||||
|
A filter that converts the given size to a human-readable format using the utils.strings.convert_size function.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
size: The size to be converted.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The human-readable size format.
|
||||||
|
"""
|
||||||
|
return convert_size(size)
|
Loading…
Reference in a new issue