summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/template/defaultfilters.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index cf1d3d5f6d..969ef7b28b 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -421,7 +421,11 @@ def filesizeformat(bytes):
Format the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102
bytes, etc).
"""
- bytes = float(bytes)
+ try:
+ bytes = float(bytes)
+ except TypeError:
+ return "0 bytes"
+
if bytes < 1024:
return "%d byte%s" % (bytes, bytes != 1 and 's' or '')
if bytes < 1024 * 1024: