|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+from decimal import Decimal as D, InvalidOperation
|
|
|
2
|
+
|
|
1
|
3
|
from django import template
|
|
2
|
4
|
from django.conf import settings
|
|
3
|
5
|
from babel.numbers import format_currency
|
|
|
@@ -10,8 +12,10 @@ def currency(value):
|
|
10
|
12
|
"""
|
|
11
|
13
|
Format decimal value as currency
|
|
12
|
14
|
"""
|
|
13
|
|
- if value is None:
|
|
14
|
|
- return ''
|
|
|
15
|
+ try:
|
|
|
16
|
+ value = D(value)
|
|
|
17
|
+ except (TypeError, InvalidOperation):
|
|
|
18
|
+ return u""
|
|
15
|
19
|
# Using Babel's currency formatting
|
|
16
|
20
|
# http://packages.python.org/Babel/api/babel.numbers-module.html#format_currency
|
|
17
|
21
|
kwargs = {
|