[Django] #34543: Thousand separator breaking templates

147 views
Skip to first unread message

Django

unread,
May 5, 2023, 1:18:29 PM5/5/23
to django-...@googlegroups.com
#34543: Thousand separator breaking templates
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
pabloriquelmecas |
Type: Bug | Status: new
Component: | Version: 4.2
Uncategorized | Keywords:
Severity: Normal | thousand_separator,thousand,separator,spanish
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi, I'm having a really weird behavior regarding the thousand separator
using the same settings as I used with Django 4.1.9 but it breaks in
Django 4.2 and 4.2.1.

The settings are
LANGUAGE_CODE = 'es-CL'
USE_THOUSAND_SEPARATOR = True
THOUSAND_SEPARATOR = "."


In Django 4.1 (tested both in 4.1.1 and 4.1.9), with the settings above,
when I call numbers on template it shows correctly like 9.800 (with the
dot specified in the thousand separator), but in Django 4.2 and 4.2.1, the
same template with the same settings shows 9 800 (with a blank space as
thousand separator), I tried switching on and off the USE_L10N and
USE_I18N but nothing happens and the documentation does not says anything
about a change of the thousand separator in templates, might be that in
the new version it could be necessary to use the humanize or similar tag
to display the thousand separator now?
It's also weird that when I set USE_THOUSAND_SEPARATOR = False, the blank
space drops and it shows 9800
This happens in all my templates

Thanks to the discord user sarahboyce for pointing a commit made to the
django project
https://github.com/django/django/commit/9f20f382cab9241f2e8ec724eb84d341a68567bc
that changes the thousand separator from a dot "." to "\xa0", and the
settings applied in settings.py does not override this.

--
Ticket URL: <https://code.djangoproject.com/ticket/34543>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 5, 2023, 1:33:29 PM5/5/23
to django-...@googlegroups.com
#34543: Thousand separator breaking templates
-------------------------------------+-------------------------------------
Reporter: Pablo Riquelme | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
thousand_separator,thousand,separator,spanish| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => needsinfo
* component: Uncategorized => Internationalization


Comment:

Hi, I don't think you've explained the issue in enough detail to confirm a
bug in Django. `THOUSAND_SEPARATOR` for the `es` language was changed
intentionally, and as [https://docs.djangoproject.com/en/4.2/ref/settings
/#thousand-separator documented]: ''"if `USE_L10N` is set to `True`, then
the locale-dictated format has higher precedence and will be applied
instead"''. Also, in Django 5.0+ the locale-dictated format always has
higher precedence.

Please reopen the ticket if you can provide a sample project that
reproduces the issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/34543#comment:1>

Django

unread,
May 5, 2023, 1:52:24 PM5/5/23
to django-...@googlegroups.com
#34543: Thousand separator breaking templates
-------------------------------------+-------------------------------------
Reporter: Pablo Riquelme | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
thousand_separator,thousand,separator,spanish| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Natalia Bidart):

Hola Pablo, could you please share an example of code that would work as
expected in Django < 4.2 but it does not work as expected in Django 4.2 or
higher? I'm not being able to reproduce the issue (in fact, neither Django
4.1 or Django 4.2 are honoring my settings, so I must be doing something
wrong).

Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/34543#comment:2>

Django

unread,
May 5, 2023, 2:06:28 PM5/5/23
to django-...@googlegroups.com
#34543: Thousand separator breaking templates
-------------------------------------+-------------------------------------
Reporter: Pablo Riquelme | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
thousand_separator,thousand,separator,spanish| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Pablo Riquelme):

In my settings I use across Django 4.1 and 4.2.

USE_I18N = True
USE_L10N = True


LANGUAGE_CODE = 'es-CL'
USE_THOUSAND_SEPARATOR = True

THOUSAND_SEPARATOR = '.'
TIME_ZONE = 'America/Santiago'


In Django 4.1 I call a model using the model.object.get(), the model has
int_value= models.IntegerField(default=0)
then I return the object to the template to show it on screen.

In my templates I call it with

Value ${{obj.int_value}}


For example, one object has int_value 15340

In the template with django up to 4.1.9, it shows "Value $15.340", the
format that i want it.
In the template with django 4.2 and 4.2.1 it shows "Value $15 340", with
the blank space instead of the dot as thousand_separator.

Django will ignore my settings of the Thousand Separator that I declared
on my settings.py, it might be that in all of this time, the setting was
ignores but de default thousand separator was the dot, until the commit
that i linked on the original ticket when it changed to a blank space.

If i change the Setting `USE_I18N` and/or `USE_L10N` and keep the other
settings intact, the only impact is that the number will lose the thousand
separator and the language of the app.

--
Ticket URL: <https://code.djangoproject.com/ticket/34543#comment:3>

Django

unread,
May 6, 2023, 2:49:40 AM5/6/23
to django-...@googlegroups.com
#34543: Thousand separator breaking templates
-------------------------------------+-------------------------------------
Reporter: Pablo Riquelme | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 4.2
Internationalization |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
thousand_separator,thousand,separator,spanish| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I would suggest you use instead custom locale format file(s):
https://docs.djangoproject.com/en/4.2/topics/i18n/formatting/#creating-
custom-format-files

--
Ticket URL: <https://code.djangoproject.com/ticket/34543#comment:4>

Reply all
Reply to author
Forward
0 new messages