Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Made floatformat filter not choke on non-floats

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1050 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 91a283583cf17b9241bd1b9882783a8aedba4d8e 1 parent 27efe14
Jacob Kaplan-Moss authored November 02, 2005

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. 5  django/core/template/defaultfilters.py
5  django/core/template/defaultfilters.py
@@ -27,7 +27,10 @@ def floatformat(text, _):
27 27
     Displays a floating point number as 34.2 (with one decimal place) -- but
28 28
     only if there's a point to be displayed
29 29
     """
30  
-    f = float(text)
  30
+    try:
  31
+        f = float(text)
  32
+    except ValueError:
  33
+        return ''
31 34
     m = f - int(f)
32 35
     if m:
33 36
         return '%.1f' % f

0 notes on commit 91a2835

Please sign in to comment.
Something went wrong with that request. Please try again.