[Django] #31006: Document how to escape a date/time format character for the |date and |time filters

16 views
Skip to first unread message

Django

unread,
Nov 19, 2019, 4:31:53 PM11/19/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters
------------------------------------------------+------------------------
Reporter: Baptiste Mispelon | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+------------------------
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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 20, 2019, 12:13:57 AM11/20/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Ryan Cheley):

* status: new => assigned
* owner: nobody => Ryan Cheley


--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:1>

Django

unread,
Nov 20, 2019, 2:38:50 AM11/20/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.

-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* 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>

Django

unread,
Nov 22, 2019, 9:44:51 PM11/22/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Nov 23, 2019, 9:52:36 AM11/23/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* 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>

Django

unread,
Nov 23, 2019, 9:56:44 AM11/23/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:5>

Django

unread,
Nov 24, 2019, 4:25:52 PM11/24/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 1, 2019, 10:02:05 AM12/1/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 2, 2019, 3:03:54 AM12/2/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: assigned
Component: Documentation | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/31006#comment:8>

Django

unread,
Dec 2, 2019, 7:55:25 AM12/2/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: closed
Component: Documentation | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* 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>

Django

unread,
Dec 2, 2019, 7:55:39 AM12/2/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Django

unread,
Dec 2, 2019, 7:56:09 AM12/2/19
to django-...@googlegroups.com
#31006: Document how to escape a date/time format character for the |date and |time
filters.
-------------------------------------+-------------------------------------
Reporter: Baptiste Mispelon | Owner: Ryan
Type: | Cheley
Cleanup/optimization | Status: closed
Component: Documentation | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages