It's only documented as part of the
[https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
:templatetag-now now] template tag:
Note that you can backslash-escape a format string if you want to use
the “raw” value. In this example, both “o” and “f” are backslash-escaped,
because otherwise each is a format string that displays the year and the
time, respectively:
It is the {% now "jS \o\f F" %}
This would display as “It is the 4th of September”.
Historically, the big table with all the available format characters used
to be next to the documentation for `{% now %}` but it was moved at some
point (to be with the documentation for `|date`.
I would suggest moving the paragraph about backslash escape under the
table of all formats instead (or least duplicating it there too).
--
Ticket URL: <https://code.djangoproject.com/ticket/31006>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* owner: nobody => Ryan Cheley
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:1>
* stage: Unreviewed => Accepted
Comment:
`date` documentation contains an example with escaped format characters:
> outputs 9 de Enero de 2008 (the DATE_FORMAT format specifier for the es
locale is r'j \d\e F \d\e Y'.
so maybe we can add a short explanation to this example, e.g.:
> outputs 9 de Enero de 2008 (the DATE_FORMAT format specifier for the es
locale is r'j \d\e F \d\e Y'). Both “d” and “e” are backslash-escaped,
because otherwise each is a format string that displays the day and the
timezone name, respectively.
I also agree to duplicate backslash example to the `time` documentation.
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:2>
Comment (by Ryan Cheley):
I have made the requested change (I think) which can be found here
[https://github.com/ryancheley/django/tree/ticket_31006]
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:3>
* has_patch: 0 => 1
Old description:
> The current documentation for the
> [https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
> :templatefilter-date date] and
> [https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
> :templatefilter-time time] filters doesn't explain how to escape a format
> character.
>
> It's only documented as part of the
> [https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
> :templatetag-now now] template tag:
>
> Note that you can backslash-escape a format string if you want to use
> the “raw” value. In this example, both “o” and “f” are backslash-escaped,
> because otherwise each is a format string that displays the year and the
> time, respectively:
> It is the {% now "jS \o\f F" %}
> This would display as “It is the 4th of September”.
>
> Historically, the big table with all the available format characters used
> to be next to the documentation for `{% now %}` but it was moved at some
> point (to be with the documentation for `|date`.
>
> I would suggest moving the paragraph about backslash escape under the
> table of all formats instead (or least duplicating it there too).
New description:
The current documentation for the
[https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
:templatefilter-date date] and
[https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
:templatefilter-time time] filters doesn't explain how to escape a format
character.
It's only documented as part of the
[https://docs.djangoproject.com/en/dev/ref/templates/builtins/#std
:templatetag-now now] template tag:
> Note that you can backslash-escape a format string if you want to use
the “raw” value. In this example, both “o” and “f” are backslash-escaped,
because otherwise each is a format string that displays the year and the
time, respectively:
> It is the {% now "jS \o\f F" %}
> This would display as “It is the 4th of September”.
Historically, the big table with all the available format characters used
to be next to the documentation for `{% now %}` but it was moved at some
point (to be with the documentation for `|date`.
I would suggest moving the paragraph about backslash escape under the
table of all formats instead (or least duplicating it there too).
--
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:4>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:5>
Comment (by Ryan Cheley):
Added example to 'time' as suggested by @felixxm here
[https://github.com/django/django/pull/12128]
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:6>
Comment (by Ryan Cheley):
Added note to 'time' as suggested by @felixxm here
https://github.com/django/django/pull/12128
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:7>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"a1f14ee3e5a2160c2eef1dad58a1da11be4b1531" a1f14ee3]:
{{{
#!CommitTicketReference repository=""
revision="a1f14ee3e5a2160c2eef1dad58a1da11be4b1531"
Fixed #31006 -- Doc'd backslash escaping in date/time template filters.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"cd7f48e85e3e4b9f13df6c0ef5f1d95abc079ff6" cd7f48e8]:
{{{
#!CommitTicketReference repository=""
revision="cd7f48e85e3e4b9f13df6c0ef5f1d95abc079ff6"
[3.0.x] Fixed #31006 -- Doc'd backslash escaping in date/time template
filters.
Backport of a1f14ee3e5a2160c2eef1dad58a1da11be4b1531 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:10>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"e8b0903976077b951795938b260211214ed7fe41" e8b09039]:
{{{
#!CommitTicketReference repository=""
revision="e8b0903976077b951795938b260211214ed7fe41"
[2.2.x] Fixed #31006 -- Doc'd backslash escaping in date/time template
filters.
Backport of a1f14ee3e5a2160c2eef1dad58a1da11be4b1531 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:11>