【问题标题】:Serializing a block of text django rest-framework and displaying paragraphs with react序列化文本块 django rest-framework 并使用 react 显示段落
【发布时间】:2020-10-10 02:56:06
【问题描述】:

我正在创建一个博客并使用 djangorestframework 作为我的后端并为我的前端做出反应。当我序列化我的数据时,我丢失了我的博客条目的格式(以段落形式编写)。有没有办法解决这个问题。

所以:

博文

This is my blog post, and this is my formatting.

My second paragraph.

成为。

[{ 
   "title": "blog post",
   content: "This is my blog post, and this is my formatting My second paragraph."
}
]

当我通过我的反应时它仍然存在

This is my blog post, and this is my formatting My second paragraph.

【问题讨论】:

    标签: json django reactjs django-rest-framework format


    【解决方案1】:

    要实现这一点,您应该在模型中将竞争字段类型定义为 TextField。

    类似的东西

    content = models.TextField(blank=True, null=True)
    

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2019-01-17
      • 2018-03-29
      • 2013-07-07
      • 1970-01-01
      • 2019-07-20
      • 1970-01-01
      • 2020-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多