一、版本
Django==1.11django-ckeditor==5.2.2
二、關鍵步驟
1.刪除舊的ckeditor靜態文件
所在目錄:項目目錄下的static文件夾下的ckditor文件夾
rm ckeditor -rf
原因:在安裝ckeditor后需要執行collectstatic命令,這個過程中的查找靜態文件會去ckeditor安裝目錄去查找靜態文件的,如果想要修改項目中的靜態文件,則直接在static目錄修改是沒有作用的,所以先把這個文件夾刪除,然后再修改ckeditor本身的內容,再執行collecstatic命令就可以使用最新的靜態文件了(備注:我的ckeditor安裝在虛擬環境中的,如果安裝在系統中修改需謹慎)
2.拷貝想要的表情文件到ckeditor指定目錄
目錄是:/lib/python3.5/site-packages/ckeditor/static/ckeditor/ckeditor/plugins/smiley/images(注意這是ckeditor的安裝目錄)
把想要的表情復制到該目錄
然后執行命令
python3 manage.py collectstatic
3.在settings.py配置表情
參考如下:
CKEDITOR_CONFIGS = {'basic': {'language': 'zh-cn',#語言'uiColor':'#E0F2F4', 'width':'200%','height':'200%',#'skin': 'moono',#'skin': 'office2013','toolbar_Basic': [['Source', '-', 'Bold', 'Italic']],'toolbar_YourCustomToolbarConfig': [{'name': 'insert','items': ['Smiley',]},],'smiley_images':['1.gif','2.gif','3.gif','4.gif','5.gif','6.gif','7.gif','8.gif','9.gif','10.gif','11.gif','12.gif','13.gif','14.gif','15.gif','16.gif','17.gif','18.gif','19.gif','20.gif','21.gif','22.gif','23.gif','24.gif','25.gif','26.gif','27.gif','28.gif','29.gif','30.gif','31.gif','32.gif','33.gif','34.gif','35.gif','36.gif','37.gif','38.gif','39.gif','40.gif','41.gif','42.gif','43.gif','54.gif','45.gif','46.gif','47.gif','48.gif','49.gif','50.gif', ],#使用哪些表情'smiley_columns':10,#控制行表情個數,此處為10個'smiley_descriptions':[],#提示文字 比如如果填 '哈哈',則當鼠標在1.gif,則出現提示文字哈哈,由于過多,此處暫時就不寫了'toolbar': 'YourCustomToolbarConfig', # put selected toolbar config here# 'toolbarGroups': [{ 'name': 'document', 'groups': [ 'mode', 'document', 'doctools' ] }],# 'height': 291,# 'width': '100%',# 'filebrowserWindowHeight': 725,# 'filebrowserWindowWidth': 940,# 'toolbarCanCollapse': True,# 'mathJaxLib': '//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-AMS_HTML','tabSpaces': 4,'extraPlugins': ','.join(['image', # add hiveme'uploadimage', # the upload image feature# your extra plugins here'div','autolink','autoembed','embedsemantic','autogrow',# 'devtools','widget','lineutils','clipboard','dialog','dialogui','elementspath']),},
}
實現的效果圖如下:
4.福利:表情包連接
http://www.lanrenzhijia.com/others/3068.html
把這個下載下來,然后把其中的images中的表情提取出來可以直接用
5.與技術無關
1.有問題歡迎留言討論
2.解決了你的問題記得頂我哦哈哈