Opened 7 years ago
Closed 7 years ago
#28544 closed Bug (fixed)
unlocalize template filter not consistent with "localize off" for datetimes - does not honor DATETIME_FORMAT
Reported by: | Beda Kosata | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 1.11 |
Severity: | Normal | Keywords: | l10n |
Cc: | 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
Hello,
according to the documentation, using {% localize off %}{{ variable }}{% endlocalize %
} should be equivalent to {{ variable|unlocalize
}}. However, for datetimes the former formats the variable according to DATETIME_FORMAT setting, while the latter does not and uses some default ISO based formatting.
To make a suggestion, I think that the source for the ulocalize filter should be:
@register.filter(is_safe=False) def unlocalize(value): """ Forces a value to be rendered as a non-localized value, regardless of the value of ``settings.USE_L10N``. """ return force_text(formats.localize(value, use_l10n=False))
instead of
@register.filter(is_safe=False) def unlocalize(value): """ Forces a value to be rendered as a non-localized value, regardless of the value of ``settings.USE_L10N``. """ return force_text(value)
Best regards
Beda
Attachments (1)
Change History (5)
by , 7 years ago
Attachment: | 28544.test.diff added |
---|
comment:1 by , 7 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 7 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Failing test