django 中的 Python 代码打印当前版权年份

Sat*_*era 1 python django bootstrap-4

如果我编写下面的 html 代码来打印我的 django 项目的当前年份,它将打印整个内容而不是仅打印年份。

\n\n
<p>\xc2\xa9Copyright xyz {% new "Y"  %}</p>\n
Run Code Online (Sandbox Code Playgroud)\n\n

输出应该是:

\n\n
\xc2\xa9Copyright xyz {% new "Y"  %}\n
Run Code Online (Sandbox Code Playgroud)\n\n

感谢任何帮助。

\n

Col*_*ole 5

我相信您打算使用内置模板标记now,您写道new

更改{% new "Y" %}{% now "Y" %},它应该输出当前年份。

Django 文档:https://docs.djangoproject.com/en/2.0/ref/templates/builtins/#now