app template_filter currency def currency product price_retail currenc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
@app.template_filter('currency')
def currency(s):
"""
<p>{{ product.price_retail|currency|safe }}</p>
"""
f = str(s).split('.')[0]
s = "{0:.2f}".format(float(s)).split('.')[1]
if len(s)>=2:
s = s[:2]
return """{0}<span class="sup">{1}</span> грн""".format(f,s)