Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13305 closed (worksforme)

date-filter doesn't use correct fallback with USE_L10N

Reported by: Horst Gutmann <horst@…> Owned by: nobody
Component: Template system Version: 1.2-beta
Severity: Keywords: l10n, templatefilters
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently the date filter doesn't respect the DATE_FORMAT as provided by a locale's formats module but instead falls back to the one defined in the global_settings. The same problem applies to the time filter. (r12937)

So for instance, even if the "de" locale is defined

somevar.pub_date|date

... will still use 'N j, Y' instead of 'j. F Y'

Attachments (0)

Change History (4)

comment:1 Changed 4 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

This is documeted behavior, from the relevant docs at http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date :

When used without a format string:

{{ value|date }}

...the formatting string defined in the DATE_FORMAT setting will be used, without applying any localization.

I'm closing this tocket worksforme, please reopen if I missed something.

comment:2 Changed 4 years ago by Horst Gutmann <horst@…>

Sorry, my bad then :-) I kind of thought that would only apply if USE_L10N was disabled.

comment:3 Changed 4 years ago by carlopires

If you want to use localized format with date filter, just put in you settings:

DATE_FORMAT = None
TIME_FORMAT = None

This forces date filter to use formats defined in custom module.

I also think the best is to change DATE_FORMAT and TIME_FORMAT defaults in settings to localized version if USE_L10N is enabled.

comment:4 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.