Django实现的博客系统中使用富文本编辑器ckeditor
2014-08-11 15:56
645 查看
操作系统为OS X 10.9.2,Django为1.6.5.
下载地址 https://github.com/shaunsephton/django-ckeditor ,下载后进入目录安装
1.2 安装 Pillow
添加 ckeditor 到 INSTALLED_APPS 中
static 和 media 的路径设置
CHEDITOR_UPLOAD_PATH 指定通过ckeditor所上传的文件的存放目录。
2.1 在admin中看到编辑页面
urls.py 文件中,设置ckeditor的url
models.py 文件中
配置完成后,即可在admin的页面中看到富文本编辑器的界面
2.2 在前台页面中看到ckeditor界面
将安装目录中的ckeditor 复制到static中
在 write.html页面中添加JS
在显示页面view.html中添加 safe 标签
参考资料:
基于django的博客系统如何完美地使用富文本编辑器ckeditor? http://www.nanerbang.com/article/2/
关于在django下使用ckeditor的步骤和技巧 http://blog.163.com/zhulp0372@yeah/blog/static/115894479201172422439697/
1.下载和安装
1.1 安装 ckeditor下载地址 https://github.com/shaunsephton/django-ckeditor ,下载后进入目录安装
django-ckeditor-master bamboo$ sudo python setup.py install
1.2 安装 Pillow
django-ckeditor-master bamboo$ easy_install Pillow
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install Pillow
2.在Django中进行配置
setting.py 文件添加 ckeditor 到 INSTALLED_APPS 中
INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'aaa', # 添加应用aaa 'bob', # 添加应用bbb 'ckeditor', # 添加应用富文本编辑器 ckeditor )
static 和 media 的路径设置
STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') CKEDITOR_UPLOAD_PATH = os.path.join(MEDIA_ROOT, 'ckeditor/uploads')
CHEDITOR_UPLOAD_PATH 指定通过ckeditor所上传的文件的存放目录。
2.1 在admin中看到编辑页面
urls.py 文件中,设置ckeditor的url
url(r'^ckeditor/', include('ckeditor.urls')), # 引入ckeditor
models.py 文件中
from django.db import models from ckeditor.fields import RichTextField class Article(models.Model): '''日志''' title = models.CharField(verbose_name='标题', max_length=150, blank=False, null=False) content = RichTextField('正文') # 使用ckeditor中的RichTextField
配置完成后,即可在admin的页面中看到富文本编辑器的界面
2.2 在前台页面中看到ckeditor界面
将安装目录中的ckeditor 复制到static中
static bamboo$ cp -ri /Library/Python/2.7/site-packages/django_ckeditor_updated-4.2.8-py2.7.egg/ckeditor/static/* /Users/workspace/myblog/static/
在 write.html页面中添加JS
<script type="text/javascript" src="/static/ckeditor/ckeditor/ckeditor.js"></script>
在显示页面view.html中添加 safe 标签
{{ article.content|safe }}
参考资料:
基于django的博客系统如何完美地使用富文本编辑器ckeditor? http://www.nanerbang.com/article/2/
关于在django下使用ckeditor的步骤和技巧 http://blog.163.com/zhulp0372@yeah/blog/static/115894479201172422439697/
相关文章推荐
- Django(博客系统):文章内容使用django-ckeditor、文章简介使用django-tinymce
- Python使用Django实现博客系统完整版
- 用Python和Django实现多用户博客系统(二)——UUBlog
- django+mysql实现一个简单的博客系统
- 【干货】利用MVC5+EF6搭建博客系统(四)(上)前后台页面布局页面实现,介绍使用的UI框架以及JS组件
- 用Python和Django实现多用户博客系统(二)——UUBlog
- 使用.net core ABP和Angular模板构建博客管理系统(实现博客列表页面)
- Django(博客系统):重写了auth.User后使用createsupperuser出错解决办法
- 【ghost】centos使用nginx实现ghost博客系统的反向代理
- Django:(博客系统)使用使用mysql数据&创建post/category/tag实体,并同步到数据中
- 从零开始,搭建博客系统MVC5+EF6搭建框架(4)上,前后台页面布局页面实现,介绍使用的UI框架以及JS组件
- 使用.net core ABP和Angular模板构建博客管理系统(实现编辑页面功能)
- 用Python和Django实现多用户博客系统——UUBlog
- Django实践:个人博客系统(第七章 Model的设计和使用)
- django轻松使用富文本编辑器CKEditor的方法
- 使用Spring boot实现开源博客系统之始
- CKEditor整合CKFinder.doc的使用 实现富文本编辑器的整合使用
- 补昨日博客-使用putty登录Windows实现虚拟机中的系统的开机、关机、重启
- 从零开始,搭建博客系统MVC5+EF6搭建框架(4)上,前后台页面布局页面实现,介绍使用的UI框架以及JS组件
- struts2中富文本编辑器使用ckeditor和ckfinder,实现富文本编辑