用的是linux,
首先把model中的代码改成:
1 def save(self):2 self.body = self.body.replace("\r\n", "\n")3 self.body = self.body.replace("\n","|safe")4 super(Diary, self).save()5
当然不知道为什么还是没用。。"<" 和 ">" 还是会被转义
两个群都没有人回答问题啊好凄惨。
先不管这个,把add diary 那个页面做好再说。
完事儿再查。
---------------------------update-------------------------------
好丢人,,模版内部内置了filter的。
linebreaks
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 }}
If value is Joel\nis a slug, the output will be Joel
is a slug. 一个filter就搞定了。。要多读文档哦