程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Django personal blog building --6-- back end data display with styles

編輯:Python

Preface :


The previous two articles described how to call the background data to be displayed on the front end , But obviously : That kind of code makes the background data appear ugly in the front-end data , With a tag or something
Results the exploration of rich text set and front-end display of rich text set in the next few days , Finally, we found a set of appropriate methods to make our articles more beautiful in the front end

The use of rich text sets :

One of my favorite rich text collections is ckeditor 了 , Interface simple , It's not hard to use
1. install django-ckeditor package :
stay terminal Enter... There pip install django-ckeditor
2.app register
stay setting.py Modification under document INSTALLED_APPS Contents of Li :

Add the last sentence
3. modify Model class
Mark the original picture

Modified into :

Remember to introduce the module at the beginning

from ckeditor.fields import RichTextField

At this time, open the site management interface

You can find this , That means we added it successfully !

The background data format is displayed in the front end :

django By default, it is not parsed casually html Code , Mainly worried about website security .

We guarantee absolute safety , Want to make django analysis html Code , You need to modify the code as follows :
Home code :

Details page code :

It looks like , Our front-end display is normal !


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved