diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index cb16e4b..e1e39dd 100644
a
|
b
|
def floatformat(text, arg=-1):
|
141 | 141 | representation of that value will be displayed. |
142 | 142 | """ |
143 | 143 | |
| 144 | if hasattr(text, '__float__'): |
| 145 | text = float(text) |
| 146 | |
144 | 147 | try: |
145 | 148 | input_val = force_unicode(text) |
146 | 149 | d = Decimal(input_val) |
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index a97596f..d86e030 100644
a
|
b
|
True
|
52 | 52 | >>> nan = pos_inf / pos_inf |
53 | 53 | >>> floatformat(nan) == unicode(nan) |
54 | 54 | True |
| 55 | >>> class FloatWrapper(object): |
| 56 | ... def __init__(self, value): self.value = value |
| 57 | ... def __float__(self): return self.value |
| 58 | ... |
| 59 | >>> floatformat(FloatWrapper(11.000001), -2) |
| 60 | u'11.00' |
| 61 | |
55 | 62 | |
56 | 63 | >>> addslashes(u'"double quotes" and \'single quotes\'') |
57 | 64 | u'\\"double quotes\\" and \\\'single quotes\\\'' |