Opened 14 years ago
Closed 14 years ago
#15263 closed New feature (fixed)
Make "now" templatetag accept locale formats.
Reported by: | Daniel Roseman | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | creecode@… | 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
The documentation on the now
tag claims that it acts like the date
filter in accepting "DATE_FORMAT" as a shortcut to the locale's current date format. However, this is not the case:
>>> t=Template("""{% now "DATE_FORMAT" %}""") >>> t.render(Context()) u'WedPMGMTE_February+0000RFebPMGMT'
Clearly the string is being interpreted as a literal format, instead of being translated to the locale's date format.
Attached patch fixes this by using the same logic as the date
filter, including a regression test, and slightly tweaks the awkward wording in the docs.
Attachments (2)
Change History (14)
by , 14 years ago
Attachment: | now_tag.diff added |
---|
comment:1 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Cc: | added |
---|---|
Has patch: | unset |
comment:3 by , 14 years ago
Has patch: | set |
---|
comment:4 by , 14 years ago
Triage Stage: | Accepted → Design decision needed |
---|
We introduced that extra paragraph about that non-existent interaction of the now tag with locale-dependent output formats in r14013 (fixing #13188) when moving the table of format specifiers from there to the date filter section.
We need to decide if we want to change the behavior of the tag to match the documentation (in which case the proposed patch can be reviewed, I haven't yet) or simply decide such change change isn't worth or sensible and then treat this ticket as documentation bug.
comment:7 by , 14 years ago
Triage Stage: | Design decision needed → Accepted |
---|
comment:8 by , 14 years ago
Severity: | → Normal |
---|---|
Summary: | "now" templatetag doesn't accept locale formats, as docs claim → Make "now" templatetag accept locale formats. |
Type: | → New feature |
With the change in the docs, it's now a feature request.
comment:9 by , 14 years ago
Easy pickings: | unset |
---|---|
Patch needs improvement: | set |
now_tag.diff fails to apply cleanly on to trunk
by , 14 years ago
Attachment: | 15263_now_tag.diff added |
---|
Sackcloth and ashes tour: Updated docs to fix patch errors and reflect new feature.
comment:10 by , 14 years ago
Patch needs improvement: | unset |
---|
comment:11 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Other than adding a '.. versionadded:: 1.4'
note for the docs this looks good to me.
The patch looks OK.