summaryrefslogtreecommitdiff
path: root/django/template
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 18:17:21 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 18:17:21 +0000
commita68c4a85ce4f80634aaaba37553db48ba3d3d8fd (patch)
tree91b0c2ce63f9eaa6ecab5bcd9a1ed4019c7cc816 /django/template
parent83c6f8d4e2ac59fdfe37296e5c7494d19beba914 (diff)
Fixed #10513: floatformat now works with floatish things, not just real floats. Thanks, Alex.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10278 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/template')
-rw-r--r--django/template/defaultfilters.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index cb16e4bbe1..673d044e5b 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -149,7 +149,9 @@ def floatformat(text, arg=-1):
except InvalidOperation:
if input_val in special_floats:
return input_val
- else:
+ try:
+ d = Decimal(force_unicode(float(text)))
+ except (ValueError, InvalidOperation, TypeError, UnicodeEncodeError):
return u''
try:
p = int(arg)