#30086: Document how floatformat template filter interacts with the localize
template tag
--------------------------------------+------------------------------------
     Reporter:  Meiyer                |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Documentation         |                  Version:  1.11
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

 * type:  Bug => Cleanup/optimization
 * component:  Template system => Documentation
 * stage:  Unreviewed => Accepted


Old description:

> Specifically, when the filter is used within the `{% localize [on|off]
> %}` block with the localization setting opposed to the value of
> `USE_L10N` ('on' when `USE_L10N = False` or 'off' when `USE_L10N =
> True`), the localization setting has not effect.
>
> This is due to the use of `formats.number_format()` without its
> `use_l10n` parameter, by the `numberformat` template filter (e.g.
> https://github.com/django/django/blob/master/django/template/defaultfilters.py#L144,
> https://github.com/django/django/blob/master/django/template/defaultfilters.py#L163).
> The value of the `use_l10n` parameter shall be taken out of the template
> rendering context. But I do not see any easy solution to this, as filters
> do not take context...

New description:

 Specifically, when the filter is used within the `{% localize [on|off] %}`
 block with the localization setting opposed to the value of `USE_L10N`
 ('on' when `USE_L10N = False` or 'off' when `USE_L10N = True`), the
 localization setting has not effect.

 This is due to the use of `formats.number_format()` without its `use_l10n`
 parameter, by the `numberformat` template filter (e.g.
 
https://github.com/django/django/blob/c2c85663e2dd06c9ed9c9ec2d02202d6d668d7f0/django/template/defaultfilters.py#L144,
 
https://github.com/django/django/blob/c2c85663e2dd06c9ed9c9ec2d02202d6d668d7f0/django/template/defaultfilters.py#L163).
 The value of the `use_l10n` parameter shall be taken out of the template
 rendering context. But I do not see any easy solution to this, as filters
 do not take context...

--

Comment:

 As long as the behavior doesn't contract existing documentation, perhaps
 the solution is the document the current behavior.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30086#comment:1>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.d5c3061717fea215c154532c43a2cb20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to