Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13054 closed (fixed)

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

Reported by: ramiro 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:

Description

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

USE_L10N = False

NUMBER_GROUPING=1
THOUSAND_SEPARATOR='!'
USE_THOUSAND_SEPARATOR=True

you get this in a manage.py 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 http://docs.djangoproject.com/en/dev/ref/settings/#use-thousand-separator 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 4 years ago.

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by ramiro

comment:1 Changed 4 years ago by russellm

  • milestone set to 1.2
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:3 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.