Usage: {{ price|dollarize }}
1 2 3 4 5 6 | @register.filter
def dollarize(c):
if c>0:
return "$%s"%c
else:
return "-$%s"%(-1*c)
|
More like this
- csrf test by zukosdead 3 days, 18 hours ago
- find even number by Rajeev529 8 months, 2 weeks ago
- Form field with fixed value by roam 9 months, 1 week ago
- New Snippet! by Antoliny0919 9 months, 2 weeks ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 1 year ago
Comments
Unless I did something wrong, it didn't return two decimal places for integers and single point precision numbers. This did the trick:
#
Please login first before commenting.