Opened 5 years ago

Last modified 3 years ago

#30086 closed Cleanup/optimization

Document how floatformat template filter interacts with the localize template tag — at Version 1

Reported by: Meiyer Owned by: nobody
Component: Template system Version: 1.11
Severity: Normal Keywords:
Cc: Florian Demmer, Carsten Fuchs Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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...

Change History (1)

comment:1 by Tim Graham, 5 years ago

Component: Template systemDocumentation
Description: modified (diff)
Summary: The numberformat template filter does not respect local localization settingsDocument how floatformat template filter interacts with the localize template tag
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

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

Note: See TracTickets for help on using tickets.
Back to Top