我的博客ni发布内容后,显示为html格式而非纯文本

After posting content of my blog ni, they are shown in html format rather than pure text

我正在为我的网络博客使用 tinymce,它允许我 post 我的博客,但是当我 post 它们以 rawHTML 格式显示时,如下所示:

这是我的模板

{% extends "blog/base.html" %}
{% load crispy_forms_tags %}
{% block styler %}

{% endblock styler%}
{% block content %}

<div class="content-section">
    <form method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        <fieldset>
            <legend class="border-bottom pb-3 mb-3">Post blog</legend>
            {{ form|crispy }}
        </fieldset>
        <button class="btn btn-outline-info" type="submit">Post</button>
    </form>
</div>

{% endblock content %}

和我的forms.py

class PostCreateForm(forms.ModelForm):
    title = forms.CharField()

    content = forms.CharField(
        widget=TinyMCEWidget(
            attrs={'required': False, 'cols': 30, 'rows': 10}
        )
    )

    thumbnail = forms.ImageField()

    class Meta:
        model = Post
        fields = ['title', 'content', 'thumbnail']

和关联 views.py

class PostCreateView(LoginRequiredMixin, CreateView):
    model = Post
    form_class = PostCreateForm

帮我解决这个问题,我搜索了一下,发现这可能是由于 @Html.Raw(@Model.LongDescription) 但我也不知道我必须在哪里添加它?请检查您是否可以对我的代码进行任何改进。 谢谢你的帮助。

通常你只需要添加安全标签:{{ content|safe }}

或者您可以将 html 包裹在自动转义标签中:

{% autoescape off %}
  {{ content }}
{% endautoescape %}