gpt4 book ai didi

python - HTML View Postgresql TextArea渲染换行符或段落-python flask

转载 作者:行者123 更新时间:2023-11-28 01:01:26 25 4
gpt4 key购买 nike

我有一个 TextAreaField,用户可以在其中写东西,但是当我在 HTML 中呈现这个 TextArea 时,文本没有换行符。但在数据库中它被正确保存。

保存在数据库中之前的用户输入:

enter image description here

数据库中的文本区域:

enter image description here

如何从数据库中呈现文本:

enter image description here

我正在使用 Flask WTForms,这是我的表单域:

infofeld = TextAreaField('Beschreibung')

那是我渲染它的代码。数据库中的列名为 "infofeld":

<p class="text"> {{ detail_room.infofeld }} </p>

最佳答案

数据库中的文本仅以“\n”作为换行符号存储。但是 html 可以用带有 PRE 标签的新行显示这样的文本:<PRE>...</PRE> .或者您可以将\n 更改为 <br><p>

关于python - HTML View Postgresql TextArea渲染换行符或段落-python flask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42027485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com