我是新手。我正在使用 Django 编写个人博客。我曾经CKEditor能够将图像插入到我的博客文章中。但是,我想在主页上显示帖子的一些第一句话,其中不包含帖子中的图像。我想知道是否有一种方法可以只从RichTextFieldin获取文本CKEditor获取文本。
这是我当前的预览内容:

我希望它是这样的(没有图像):

这是我当前的代码:
{% for post in post_list %}
<div class="card mb-4">
<div class="card-body">
<h2 class="card-title">{{ post.title }}</h2>
<p class="card-text text-muted h6">{{ post.Author }} | {{ post.created_on}} </p>
<p class="card-text">{{post.content|safe|truncatewords:20 }}</p>
<a href="{% url 'post_detail' post.slug %}" class="btn btn-primary">Read More →</a>
</div>
</div>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)