Where does django read request language code and sneak it into DecimalField output? -
i'm little confused why site rendering commas decimal separators.
i've disabled use_l10n
should take care of issue, i'm still curious per request language code decimalfield magic happening. there no instances of localize=true
anywhere in codebase.
my thought browser requests language code other en-us
, django automatically responds converting decimal fields, can't seem find happens in django 1.4
source.
example here: click through products , watch price deicmal separator. http://www.grovemade.com/product/iphone-5-case/#amongshadows-bamboo-iphone-5-case
the output cached per url w/o regard language code why you're seeing prices decimal separators ,
vs .
. ones 0,00
must have been cached non en-us
accept request.
to answer question happening, in the template system:
def _render_value_in_context(value, context): """ converts value string become part of rendered template. means escaping, if required, , conversion unicode object. if value string, expected have been translated. """ value = localtime(value, use_tz=context.use_tz) value = localize(value, use_l10n=context.use_l10n) value = force_unicode(value) if ((context.autoescape , not isinstance(value, safedata)) or isinstance(value, escapedata)): return escape(value) else: return value
localize
django.utils.formats
:
def localize(value, use_l10n=none): """ checks if value localizable type (date, number...) , returns formatted string using current locale format. if use_l10n provided , not none, force value localized (or not), overriding value of settings.use_l10n. """ if isinstance(value, bool): return mark_safe(six.text_type(value)) elif isinstance(value, (decimal.decimal, float) + six.integer_types): return number_format(value, use_l10n=use_l10n) elif isinstance(value, datetime.datetime): return date_format(value, 'datetime_format', use_l10n=use_l10n) elif isinstance(value, datetime.date): return date_format(value, use_l10n=use_l10n) elif isinstance(value, datetime.time): return time_format(value, 'time_format', use_l10n=use_l10n) else: return value
i think what's happening template setting localize somewhere true, overriding settings use_l10n
setting.
or may have stale settings files still in use. try clearing out .pyc
, cache , try again.
Comments
Post a Comment