【发布时间】:2013-09-09 15:36:50
【问题描述】:
我正在使用 python 语言在 django 平台上工作。我在我的模板文件中显示结果,其中我有很大的描述要显示。我只想知道如果文本超过 4 行,我们如何在大描述上设置“查看更多”选项。在 4 行之后将出现“查看更多”选项。就像 Facebook 的长状态一样。并单击“查看更多”选项,我想显示我的整个描述。我是 django 的新手,将不胜感激。
这是我的代码
<span class="results-cell-heading">{% trans "Description:" %}</span>
<span class="results-cell">{% autoescape off %}{{ obj.description }}
{% endautoescape %}</span>
这里的{{obj.description}} 是描述文本。
【问题讨论】:
-
它确实解决了问题,但导致了另一个问题。就像如果他们没有关于该字段的数据,那么仍然会看到更多选项显示
标签: python html django django-templates word-wrap