Django 出现:Could not parse the remainder: 'date::'Y /m /d''

编程入门 行业动态 更新时间:2024-10-07 00:15:55

Django 出现:Could not <a href=https://www.elefans.com/category/jswz/34/1757281.html style=parse the remainder: 'date::'Y /m /d''"/>

Django 出现:Could not parse the remainder: 'date::'Y /m /d''

在项目中练习中使用动态Url的时候在日期format的时候出现:

Could not parse the remainder: ‘:date:’Y /m /d” from ‘post.date_time:date:’Y /m /d”

这里主要是自己跟着练习的时候出现疏忽了,原代码是:

{% extends "base.html"%}
{% block content %}
<div class="posts"><section class="post"><header class="post-header"><h2 class="post-title">{{post.title}}</h2><--!主要是这里出现了问题--><p class="post-meta">Time: <a class="post-author" href="#">{{post.date_time:date:'Y /m /d'}}</a><a class="post-category-js" href="#">{{post.category}}</a></p><div class="post-description"><p>{{post.content}}</p></div></header></section>
</div>
{% endblock %}

修改后的代码为:

 <p class="post-meta">Time: <a class="post-author" href="#">{{post.date_time|date:'Y /m /d'}}</a><a class="post-category-js" href="#">{{post.category}}</a></p>

主要是把: 改为| 了, 这样子就解决了日期format的问题。

更多推荐

Django 出现:Could not parse the remainder: 'date::'Y /m /d''

本文发布于:2024-02-07 02:55:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1752553.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:parse   Django   date   remainder

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!