Created
January 1, 2018 20:00
-
-
Save andrekeller/fc6aeccce255c1abc2381da3e93ba894 to your computer and use it in GitHub Desktop.
django-currency-filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django import template | |
from django.utils.translation import get_language, to_locale | |
import locale | |
locale.setlocale(locale.LC_ALL, locale="{}.utf8".format(to_locale(get_language()))) | |
register = template.Library() | |
@register.filter | |
def currency(value): | |
if value is None: | |
return None | |
return locale.currency(value, grouping=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment