Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#13054 closed (fixed)

integer part grouping settings does not respect USE_L10N setting value, changes behavior of floatformat

Reported by: Ramiro Morales Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


(An offspring of #13032) If, for example, you have this in your settings:

USE_L10N = False


you get this in a shell session:

In [1]: from django.template import Template, Context

In [2]: Template('{{ n|floatformat }}').render(Context({'n': 100}))
Out[2]: u'1!0!0'

i.e. the thousand and grouping formatting settings values get used even if USE_L10N is False. This is either a code implementation bug or our documentation at isn't clear enough.

I'm inclined to think it is a bug because this hypothetical scenario: An user has set NUMBER_GROUPING to a value > 0 and USE_THOUSAND_SEPARATOR = True but sets USE_L10N = False thinking it's a master switch that turns the locale-aware formatting machinery off. But the floatformat filter still messes with the part to the left of the decimal separator.

The default value of NUMBER_GROUPING is 0 and that's why we haven't seen report of this yet.

Attachments (1)

13054.diff (6.4 KB) - added by Ramiro Morales 7 years ago.

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by Ramiro Morales

Attachment: 13054.diff added

comment:1 Changed 7 years ago by Russell Keith-Magee

milestone: 1.2
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

(In [12816]) Fixed #13054 - Only apply grouping to integer part of numbers if explicitly wanted. Thanks, Ramiro Morales.

comment:3 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top