django - Django 内容片段
问题描述
我想在 100 片后显示一个“...更多”标签以显示完整的评论内容,有人可以帮忙吗?
模板:
<div class="comment">
{% for comment in post.comment_set.all %}
<p>{{ comment.content| linebreaks}}</p>
<p>{{ comment.content|slice:":100"|linebreaksbr}}
{% if comment.content|length > 100 %}
????
{% endif %}</p>
解决方案
推荐阅读
- r - R:试图理解逻辑以便用 lapply() 替换循环
- go - 为什么 io.Copy 会引发 NetworkIdleTimeout 错误?
- javascript - Javascript将对象放入数组中
- r - 与 R 中的 API 错误交互以进行循环
- javascript - 路由转换在 nuxt.js + electron.js 中不起作用
- apache - Apache htaccess:无法同时使用 RewriteCond HTTPS 和 HTTP_USER_AGENT
- php - 创建自定义 woocommerce 结帐模板
- kubernetes - 如何在谷歌 Kubernetes 引擎上增加主节点的大小?
- c# - 如何在 Azure fluent API for SQL Server 中为现有数据库设置服务器级别目标(定价层)?
- c# - 错误:在尝试连接两个数据表时找不到源类型数据表的查询实现和未找到连接