首页 > Django > 正文

Django2 install ckeditor

标签:django

打开命令行窗口:

pip install –user django-ckeditor(if use python3.x , then pip3 install –user django-ckeditor)

mysite/settings.py file:

INSTALLED_APPS = (
                   ...
                  'ckeditor',
                  )

CKEDITOR_UPLOAD_PATH = 'uploads/'
CKEDITOR_RESTRICH_BY_USER = True
CKEDITOR_CONFIGS = {
           'default':{
           'toolbar':'Advanced',
           'width':800,
           'height':300,
},
}

mysite/urls.py

urlpatterns = [
    ...
    url('ckeditor/', include('ckeditor_uploader.urls')),
]

mysite/blog/models.py

from ckeditor.fields import RichTextField
class Post(models.Model):
    body = models.TextField()-->change to body = RichTextField()

更新数据库收集静态文件

AltText

最后,django不能读ckeditor产生的html标签, 代替用print , 修改这个问题:

AltText


原创文章,转载请注明出处!
本文链接:moonbrillante.github.io/posts/django2.html
上篇: Django1 Create a Blog
下篇: Python(6) 类