首页 > django后台文本数据如何保持与前台格式相同?

django后台文本数据如何保持与前台格式相同?

这是在后台编辑的状态

这是它的model

到了前台就这样了:

前台的代码:

<div class="container">
  <div class="starter-template">
    <div class="col-xs-12">
          <table class="table table-striped ">
            <tr>
                <td >
                  <font size=6 face=楷体>
                    {% if log_context %}
                    {{ log_context.log_title }}
                    {% else %}
                      已侦测到错误 X1
                    {% endif %}
                  </font>
                </td>
            </tr>
            <tr>
                <td >
                  <font size=3 face=楷体>
                    {% if log_context %}
                    {{ log_context.timestamp }}
                    {% else %}
                      已侦测到错误 X2
                    {% endif %}
                  </font>
                </td>
            </tr>
            <tr>
              <td >
                  <font size=4 face=楷体>
                    {% if log_context %}
                    {{ log_context.body }}
                    {% else %}
                      已侦测到错误 X3
                    {% endif %}
                  </font>
               </td>
            </tr>
          </table>
      </div>
  </div>
</div>

用了bootstrap。
那么如何让前台的文章显示像后台一样有换行符?而不是这么不美观。


自己解决了。用一个pre标签就可以解决了,然后再写一下关于换行的css:

pre{
white-space:pre-wrap; /* css3.0 */
white-space:-moz-pre-wrap; /* Firefox */
white-space:-pre-wrap; /* Opera 4-6 */
white-space:-o-pre-wrap; /* Opera 7 */
word-wrap:break-word; /* Internet Explorer 5.5+ */
} 
【热门文章】
【热门文章】