开发者

django handle newlines in textarea

开发者 https://www.devze.com 2023-03-12 18:20 出处:网络
<textarea id=\"my\" ></textarea> p=post(body=value) p.save() Here I am trying to save the content of the textarea to database开发者_开发问答 but i see that new lines are converted to sp
  <textarea id="my" ></textarea>

  p=post(body=value)
  p.save()

Here I am trying to save the content of the textarea to database开发者_开发问答 but i see that new lines are converted to spaces and then saved.How to handle this on the server side..


They're almost certainly not being converted to new-lines, the problem is likely to be the way you're displaying them.

Try displaying them in your template using the linebreaks filter, like this:

{{ mypost.body|linebreaks }}
0

精彩评论

暂无评论...
验证码 换一张
取 消