Made floatformat filter not choke on non-floats
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1050 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
27efe14c54
commit
91a283583c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue