#33281: intcomma template filter doesn't depend on the USE_L10N setting.
----------------------------------+--------------------------------------
     Reporter:  Demetris Stavrou  |                    Owner:  nobody
         Type:  Uncategorized     |                   Status:  closed
    Component:  Template system   |                  Version:  3.2
     Severity:  Normal            |               Resolution:  invalid
     Keywords:                    |             Triage Stage:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------

Comment (by Demetris Stavrou):

 Thank you for suggesting how to solve this problem on my project. However,
 the reason I opened this ticket was to help improve Django development
 experience. I do believe that the documentation could improve to better
 explain how this works. Honestly, it is not clear to me yet, what is going
 on. I am walking you through my thought process, when looking at the
 documentation:

 > Note, however, that to enable number formatting with thousand separators
 it is necessary to set USE_THOUSAND_SEPARATOR = True in your settings
 file. Alternatively, you could use intcomma to format numbers in your
 template.

 Starting from here, even if I use `USE_THOUSAND_SEPARATOR=True` the `{{
 <big_number> }}` is still rendered as `123456789 `. But based on the
 documentation it should work, right? So going further in the
 documentation:

 > When set to True and USE_L10N is also True, Django will format numbers
 using the NUMBER_GROUPING and THOUSAND_SEPARATOR settings.

 From here, I am a bit confused as it is not clear whether I can use the
 setting if `USE_L10N = False`. The sentence implies that I can use it in
 either case. I also set `NUMBER_GROUPING = 3` and `THOUSAND_SEPARATOR =
 ","` as the documentation suggests. The `{{ <big_number> }}` is still
 rendered as `123456789 `.

 At this point I also try and set `USE_L10N = True`. The `{{ <big_number>
 }}` is now rendered as `123.456.789 `. So the thousand separator now
 works, but with the wrong character. This makes sense because the locale I
 am using dictates `.` as the separator. However, the project requires `,`
 as the separator. Going back to the documentation:

 > These settings may also be dictated by the locale, which takes
 precedence.

 So the behavior I am seeing is correct, but I am stuck, because if I
 remove the locale, the the separator disappears as well.

 I am not sure what I am missing here, but is seems to me that the
 separator settings make sense only when the localization is False, since
 it takes precedence. But they don't seem to work at all.

 I respect the decision of the maintainers to consider this as not an issue
 and I am just including the above in case they are useful (I am not
 expecting an answer).

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.b5da102913e9510e3e2aa9f2ec7db634%40djangoproject.com.

Reply via email to