将 CKEditor 添加到 Django 项目
Adding CKEditor to Django project
有人可以指导我在我的 Django 项目中安装 CKEditor 的正确方向吗?我对此很陌生,所以解释得越透彻,对我的帮助就越大。
我找到了这个 link,但它对我来说效果不是很好:http://docs.ckeditor.com/#!/guide/dev_installation。
非常感谢!
pip install ckeditor
- 在项目 [已安装的应用] 的设置中添加 -ckeditor-
用于视频嵌入的管理员 CK 编辑器
CKEDITOR_UPLOAD_PATH = root('uploads')
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'Advanced',
'width': 758,
'height': 300,
},
}
用于视频嵌入的管理员 CK 编辑器
在项目中创建文件夹uploads
将此 url 添加到您的主 urls.py
url(r'^ckeditor/', include('ckeditor.urls')),
将此添加到您的 models.py
from ckeditor.fields import RichTextField
content = RichTextField(verbose_name='BlogContent',null=True,blank=True)
确保在 运行 你的项目之前做 python manage.py collectstatic
。
还有另一种将 CKeditor 集成到 Django 的方法,使用 Javascript 版本的 CKeditor。
从http://ckeditor.com/download下载ckeditor并解压zip文件,将解压后的文件夹放在静态根目录下。将 ckeditor 静态文件添加到您的模板中,例如:
<script src="{{STATIC_URL}}ckeditor/ckeditor.js"></script>
在您的表单中,像这样添加 html class:
class SomeForm(forms.Form):
text = forms.CharField(widget = forms.Textarea(attr={'class':'richtexteditor'})
要使此富文本编辑器可见,请在您的模板中添加以下行:
<script>
CKEDITOR.replace( '.richtexteditor' );
</script>
有人可以指导我在我的 Django 项目中安装 CKEditor 的正确方向吗?我对此很陌生,所以解释得越透彻,对我的帮助就越大。
我找到了这个 link,但它对我来说效果不是很好:http://docs.ckeditor.com/#!/guide/dev_installation。
非常感谢!
pip install ckeditor
- 在项目 [已安装的应用] 的设置中添加 -ckeditor-
用于视频嵌入的管理员 CK 编辑器
CKEDITOR_UPLOAD_PATH = root('uploads')
CKEDITOR_RESTRICT_BY_USER = True
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'Advanced',
'width': 758,
'height': 300,
},
}
用于视频嵌入的管理员 CK 编辑器
在项目中创建文件夹uploads
将此 url 添加到您的主
urls.py
url(r'^ckeditor/', include('ckeditor.urls')),
将此添加到您的 models.py
from ckeditor.fields import RichTextField content = RichTextField(verbose_name='BlogContent',null=True,blank=True)
确保在 运行 你的项目之前做 python manage.py collectstatic
。
还有另一种将 CKeditor 集成到 Django 的方法,使用 Javascript 版本的 CKeditor。
从http://ckeditor.com/download下载ckeditor并解压zip文件,将解压后的文件夹放在静态根目录下。将 ckeditor 静态文件添加到您的模板中,例如:
<script src="{{STATIC_URL}}ckeditor/ckeditor.js"></script>
在您的表单中,像这样添加 html class:
class SomeForm(forms.Form):
text = forms.CharField(widget = forms.Textarea(attr={'class':'richtexteditor'})
要使此富文本编辑器可见,请在您的模板中添加以下行:
<script>
CKEDITOR.replace( '.richtexteditor' );
</script>