我有一个带有属性的模型,
desc = models.TextField()
我使用 Django 提供的管理界面输入数据,然后查看我的模板,其中获取并显示了数据库值。
在我的管理界面中,我留下了换行符(只是在我的段落之间留下了空行),但它们在我的模板中显示为单个段落。
我正在使用 Django 1.3 和 MySQL。
最佳答案
Replaces line breaks in plain text with appropriate HTML; a single newline becomes an HTML line break (
<br />
) and a new line followed by a blank line becomes a paragraph break (</p>
).For example:
{{ value|linebreaks }}
关于django - models.TextField() 中的换行符未在模板中呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10270891/