Skip to content

Instantly share code, notes, and snippets.

@andrekeller
Created January 1, 2018 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrekeller/fc6aeccce255c1abc2381da3e93ba894 to your computer and use it in GitHub Desktop.
Save andrekeller/fc6aeccce255c1abc2381da3e93ba894 to your computer and use it in GitHub Desktop.
django-currency-filter
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