1

TextField在 django 中使用,我有一个表格供用户输入段落。我希望用硬包装保存这段文字,以便以后显示时在间距和缩进方面看起来完全相同。

当我使用管理工具进入段落时,它会按照我的意愿出现。但是,当我在模板中引用它时,所有句子都流在一起,没有正确的间距和换行符。在模板中使用时如何使 TextField 硬包装?

这是我的 TextField 声明:

class Description(models.Model):
summary=models.TextField(verbose_name="My Summary")

我通过管理员输入以下示例:

Hi I am using TextField in django and I have a form for the user to enter a passage. 

I want this passage to be saved with hard wrap in such a way that it appears the exact
same in terms of spacing and indentation and what not. When I use the admin to enter
the passage,

It appears as I want it but when I reference it on a template. All the sentences follow
up without the correcect spacing and newlines. how do I achieve this please

info=Description.objects.get(pk=1)当我在视图或{{ info }}模板中使用时,它看起来并不完全像上面那样。

4

0 回答 0