diff options
| author | Ryan Cheley <rcheley@gmail.com> | 2019-11-22 18:38:27 -0800 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-02 13:07:38 +0100 |
| commit | a1f14ee3e5a2160c2eef1dad58a1da11be4b1531 (patch) | |
| tree | d71cfd23d860ea5f54f0bc93c7d4b730ff5a8039 /docs | |
| parent | 3b347a8a00273e9cc2fd9d4a5c61569c08398769 (diff) | |
Fixed #31006 -- Doc'd backslash escaping in date/time template filters.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/templates/builtins.txt | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt index cc572583ee..24ad8c433d 100644 --- a/docs/ref/templates/builtins.txt +++ b/docs/ref/templates/builtins.txt @@ -1451,7 +1451,9 @@ used. Assuming the same settings as the previous example:: {{ value|date }} outputs ``9 de Enero de 2008`` (the ``DATE_FORMAT`` format specifier for the -``es`` locale is ``r'j \d\e F \d\e Y'``. +``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. You can combine ``date`` with the :tfilter:`time` filter to render a full representation of a ``datetime`` value. E.g.:: @@ -2177,6 +2179,15 @@ For example:: If ``value`` is equivalent to ``datetime.datetime.now()``, the output will be the string ``"01:23"``. +Note that you can backslash-escape a format string if you want to use the +"raw" value. In this example, both "h" and "m" are backslash-escaped, because +otherwise each is a format string that displays the hour and the month, +respectively:: + + {% value|time:"H\h i\m" %} + +This would display as "01h 23m". + Another example: Assuming that :setting:`USE_L10N` is ``True`` and :setting:`LANGUAGE_CODE` is, |
