[Django] #37118: Support variables in the {% now %} template tag

18 views
Skip to first unread message

Django

unread,
May 22, 2026, 4:53:10 PM (8 days ago) May 22
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
----------------------+-------------------------------------------
Reporter: Lily | Type: New feature
Status: new | Component: Template system
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------+-------------------------------------------
This was discussed and accepted in https://github.com/django/new-
features/issues/115.

Allow passing a variable from the template context into the `{% now %}`
template tag to allow dynamically choosing the formatting.

[https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#now
Django's `{% now %}` template tag] currently only supports a hardcoded
string format defined directly in the template, or one of a small number
of specific settings. By supporting template variables, it would be
possible to change the `format` dynamically (for example, based on a
user's locale).

[https://blog.lilyf.org/posts/django-template-quirks-3/#the--now--tag As I
explain in my blog post], the `now` tag has some very weird behaviour
caused by assuming the `format` will always be a string. By expanding to
support variables, we can also clean up these weird edge-cases by raising
a `TemplateSyntaxError`.

Several other template tags support variables, so it should be fairly easy
to reuse their implementation of this.
--
Ticket URL: <https://code.djangoproject.com/ticket/37118>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 23, 2026, 3:00:09 AM (8 days ago) May 23
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+--------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by ZKY):

* owner: (none) => ZKY
* status: new => assigned

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

Django

unread,
May 24, 2026, 3:15:57 AM (7 days ago) May 24
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+--------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by ZKY):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37118#comment:2>

Django

unread,
May 24, 2026, 3:18:47 AM (7 days ago) May 24
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+--------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Comment (by ZKY):

I have submitted PR #21349 for this feature. Would a triager please update
the Triage Stage to Accepted so that the GitHub CI checks can run? Thank
you very much!
--
Ticket URL: <https://code.djangoproject.com/ticket/37118#comment:3>

Django

unread,
May 25, 2026, 12:27:15 AM (6 days ago) May 25
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by JaeHyuckSa):

* stage: Unreviewed => Accepted

--
Ticket URL: <https://code.djangoproject.com/ticket/37118#comment:4>

Django

unread,
May 25, 2026, 2:28:18 AM (6 days ago) May 25
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Comment (by ZKY):

Hello, my previous PR was closed because the ticket hadn't reached the
'Accepted' status. Here is my new PR:
https://github.com/django/django/pull/21357. Thank you
--
Ticket URL: <https://code.djangoproject.com/ticket/37118#comment:5>

Django

unread,
May 26, 2026, 9:55:49 AM (4 days ago) May 26
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Tim McCurrach):

* needs_better_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37118#comment:6>

Django

unread,
May 28, 2026, 2:36:39 AM (3 days ago) May 28
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by ZKY):

* needs_better_patch: 1 => 0

--
Ticket URL: <https://code.djangoproject.com/ticket/37118#comment:7>

Django

unread,
May 28, 2026, 2:36:50 AM (3 days ago) May 28
to django-...@googlegroups.com
#37118: Support variables in the {% now %} template tag
---------------------------------+------------------------------------
Reporter: Lily | Owner: ZKY
Type: New feature | Status: assigned
Component: Template system | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Comment (by ZKY):

Updated the PR to address the review comments. All checks are passing now.
Please take another look, thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/37118#comment:8>
Reply all
Reply to author
Forward
0 new messages