misc: override intcomma to always be called on decimals (#46346) #586
|
@ -1579,3 +1579,10 @@ def test_stripsometags(pub):
|
|||
assert Template('{{ value|stripsometags:"p,br,h1,ul,li" }}').render(context) == (
|
||||
'<h1>title 1</h1>my-script<p>foo</p>link<br />strong<ul><li>li 1</li><li>li 2</li></ul>'
|
||||
)
|
||||
|
||||
|
||||
def test_intcomma(pub):
|
||||
context = {'value': '20345.20'}
|
||||
assert Template('{{ value|intcomma }}').render(context) == '20,345.2'
|
||||
with override_settings(LANGUAGE_CODE='fr-fr'):
|
||||
assert Template('{{ value|intcomma }}').render(context) == '20 345,2'
|
||||
|
|
|
@ -45,6 +45,7 @@ except ImportError:
|
|||
langdetect = None
|
||||
|
||||
from django import template
|
||||
from django.contrib.humanize.templatetags.humanize import intcomma as humanize_intcomma
|
||||
from django.template import defaultfilters
|
||||
from django.utils import dateparse
|
||||
from django.utils.encoding import force_bytes, force_str
|
||||
|
@ -1149,3 +1150,8 @@ def default_if_none(value, arg):
|
|||
if value is None:
|
||||
return arg
|
||||
return value
|
||||
|
||||
|
||||
@register.filter(is_safe=True)
|
||||
def intcomma(value):
|
||||
return humanize_intcomma(decimal(value))
|
||||
|
|
|
@ -102,9 +102,9 @@ TEMPLATES = [
|
|||
'django.template.loaders.app_directories.Loader',
|
||||
],
|
||||
'builtins': [
|
||||
'wcs.qommon.templatetags.qommon',
|
||||
'django.templatetags.l10n',
|
||||
'django.contrib.humanize.templatetags.humanize',
|
||||
'wcs.qommon.templatetags.qommon',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue