Opened 3 years ago

Closed 3 years ago

Last modified 18 months ago

#25758 closed Bug (fixed)

Date filter doesn't use internationalization when USE_L10N is True

Reported by: Ali Lozano Owned by: nobody
Component: Template system Version: 1.8
Severity: Normal Keywords: date, format, internationalization
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

Date filter uses settings.DATE_FORMAT by default to format dates, and ignore if django is using internationalization and USE_L10N is True

{{ user.date_joined|date }}

Always format with N j, Y

Maybe this is no a problem because date filter uses to use with a arg, but naturalday filter(of humanize) uses date filter to format dates.

Change History (10)

comment:2 Changed 3 years ago by Tim Graham

Could you please add a test to demonstrate what this fixes?

comment:3 Changed 3 years ago by Tim Graham

Has patch: set
Needs tests: set
Triage Stage: UnreviewedAccepted

I'll accept the ticket since no tests fail if that line from the pull request is removed (same with if arg is None: arg = settings.TIME_FORMAT in the time filter, but we still need a test to show what this fixes.

comment:4 Changed 3 years ago by Claude Paroz

Needs tests: unset

New PR with tests (and including the time filter).

comment:5 Changed 3 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:6 Changed 3 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In be9bd334:

Fixed #25758 -- Defaulted to current language FORMATs in date/time filters

Thanks Ali Lozano for the report and the initial patch, and Tim Graham for
the review.

comment:7 Changed 18 months ago by Tim Graham

It looks like this changed a documented behavior, see #27981.

comment:8 Changed 18 months ago by Tim Graham <timograham@…>

In 6585ebe:

Fixed #27981 -- Doc'd date/time filter l10n changes in refs #25758.

comment:9 Changed 18 months ago by Tim Graham <timograham@…>

In 28cf32b:

[1.11.x] Fixed #27981 -- Doc'd date/time filter l10n changes in refs #25758.

Backport of 6585ebebaaa58aeef45210a3119dbaa322f8baca from master

comment:10 Changed 18 months ago by Tim Graham <timograham@…>

In 16b97a2:

[1.10.x] Fixed #27981 -- Doc'd date/time filter l10n changes in refs #25758.

Backport of 6585ebebaaa58aeef45210a3119dbaa322f8baca from master

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