Django后台安装富文本编辑器
models.py
from django.db import models
# Create your models here.
class Show(models.Model):
content = models.TextField('内容',blank=True)
admin.py
from django.contrib import admin
from apps.File.models import Show
# Register your models here.
@admin.register(Show)
class ShowAdmin(admin.ModelAdmin):
class Media:
js = (
'/static/kindeditor-master/kindeditor-all.js',#这是在后台的页面中追加js文件
'/static/kindeditor-master/lang/zh-CN.js',
'/static/kindeditor-master/config.js',
)
新建的config.js
/**
* Created by 14903 on 2020/6/14.
*/
KindEditor.ready(function (k) {
window.editor = k.create('textarea[name="content"]',{
//resizeType:1,
//allowPreviewEmoticons : false,
//allowImageRemote : false,
uploadJson : '/admin/upload/kindeditor',
height:'400px',
width:'800px'
});
})
'textarea[name="content"]'
这玩意就是你创建的字段在admin页面上显示的标签,可以使用F12查找元素