diff --git a/django/core/template/defaultfilters.py b/django/core/template/defaultfilters.py index 2604caf7f9..3a25add5e1 100644 --- a/django/core/template/defaultfilters.py +++ b/django/core/template/defaultfilters.py @@ -27,7 +27,10 @@ def floatformat(text, _): Displays a floating point number as 34.2 (with one decimal place) -- but only if there's a point to be displayed """ - f = float(text) + try: + f = float(text) + except ValueError: + return '' m = f - int(f) if m: return '%.1f' % f