mirror of
https://github.com/django/django.git
synced 2025-04-01 12:06:43 +00:00
Fixed #403 -- Fixed bug in floatformat template filter. Thanks, nesh
git-svn-id: http://code.djangoproject.com/svn/django/trunk@581 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
cb6aa1035b
commit
9635ac07a5
@ -23,14 +23,15 @@ def fix_ampersands(value, _):
|
|||||||
|
|
||||||
def floatformat(text, _):
|
def floatformat(text, _):
|
||||||
"""
|
"""
|
||||||
Displays a floating point number as 34.2 (with one decimal places) - but
|
Displays a floating point number as 34.2 (with one decimal place) - but
|
||||||
only if there's a point to be displayed
|
only if there's a point to be displayed
|
||||||
"""
|
"""
|
||||||
|
from math import modf
|
||||||
if not text:
|
if not text:
|
||||||
return ''
|
return ''
|
||||||
if text - int(text) < 0.1:
|
if modf(float(text))[0] < 0.1:
|
||||||
return int(text)
|
return text
|
||||||
return "%.1f" % text
|
return "%.1f" % float(text)
|
||||||
|
|
||||||
def linenumbers(value, _):
|
def linenumbers(value, _):
|
||||||
"Displays text with line numbers"
|
"Displays text with line numbers"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user