Code

Opened 6 years ago

Closed 2 years ago

#9037 closed New feature (fixed)

django.contrib.humanize new filter (dotint)

Reported by: waa Owned by: nobody
Component: contrib.humanize Version: master
Severity: Normal Keywords: contrib humanize
Cc: semente@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Converts an integer to a string containing dots every three digits. In Brazil we use dot not commas to separate numbers and is possible other location around the world use it too.

Attachments (2)

humanize_intdot.diff (2.4 KB) - added by waa 6 years ago.
humanize_intcomma_locale_specific.diff (577 bytes) - added by erickd 5 years ago.

Download all attachments as: .zip

Change History (14)

Changed 6 years ago by waa

comment:1 Changed 6 years ago by Guilherme M. Gondim <semente@…>

  • Cc semente@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by Guilherme M. Gondim <semente@…>

  • Patch needs improvement set

comment:3 Changed 6 years ago by mtredinnick

  • milestone post-1.0 deleted
  • Triage Stage changed from Unreviewed to Design decision needed

This is probably not the right approach for something in core. Rather, we should make the existing filter locale-aware when we put that stuff in (the plan is to include locale data for things like numeric separators and date formats). Then the existing filter will use dots or commas as appropriate for the page's locale.

So I'm -1 on this at the moment.

comment:4 Changed 6 years ago by waa

Malcolm,
You think an approach like DATE_FORMAT, when each country has the possibility to change the default behavior of date format is the correct? What you think to create some options like NUMERIC, MONETARY, TELEPHONE and MEASUREMENT to be used internally for numeric separators, date formats, monetary values, telephone displaying and validation and measurement.

comment:5 in reply to: ↑ description Changed 5 years ago by finngruwier

Replying to waa:

Converts an integer to a string containing dots every three digits. In Brazil we use dot not commas to separate numbers and is possible other location around the world use it too.

Same in many European locales. The dot is probably used in more locales then the comma.

comment:6 Changed 5 years ago by justinlilly

  • Component changed from Uncategorized to Contrib apps

Changed 5 years ago by erickd

comment:7 Changed 5 years ago by anonymous

This issue definitely warrants some more attention in the long run, but how about doing something simple and effective for now (see attached diff). Would this make most people happy?

comment:8 Changed 5 years ago by erickd

This issue definitely warrants some more attention in the long run, but how about doing something simple and effective for now (see attached diff). Would this make most people happy?

comment:9 Changed 5 years ago by mtredinnick

If people want something "for now", they are free to include this filter in their code; there is absolutely nothing requiring this to be part of Django. We are not in the habit of intentionally including half-baked solutions in the core code, however. It can wait for the full-scale solution, rather than having people write code using distributed Django that contains something which is already effectively end-of-lifed.

comment:10 Changed 3 years ago by gabrielhurley

  • Component changed from Contrib apps to contrib.humanize

comment:11 Changed 3 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

comment:12 Changed 2 years ago by aaugustin

  • Easy pickings unset
  • Resolution set to fixed
  • Status changed from new to closed
  • UI/UX unset

This feature is now provided by the THOUSAND_SEPARATOR and NUMBER_GROUPING — from the settings when USE_L10N = False, and each locale's formats.py when USE_L10N = True.

The values for pt_BRare correct:

THOUSAND_SEPARATOR = '.'
NUMBER_GROUPING = 3

All this probably didn't exist when the ticket was opened.

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.