如何在HTML {{post.published_date}}标签处省略时间?

Jon*_*Ahn 2 python django

如何在HTML {{ post.published_date }}标签上节省时间?

我使用Python和Django,我尝试显示发布日期,但是我不想显示时间。

<!--html file-->
<a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }} ... &nbsp {{ post.published_date }}</a>
Run Code Online (Sandbox Code Playgroud)

例如

是)我有的:

  • 这是职位标题... 2019年11月19日下午5:37
  • 这也是职务!... 2019年11月24日上午2:30

我想要的是:

  • 这是职位名称。2019年19月19日
  • 这也是职务!...十一月 2019年24月

arj*_*jun 7

如果只希望模板中有日期,请尝试此操作。有关更多信息,请参阅文档

{{ post.published_date|date }}
Run Code Online (Sandbox Code Playgroud)