java中的接口是类吗
347
2022-08-31
Django admin 结合富文本编辑器tinymce(django和flask的区别)
后台需要加入富文本编辑器于是选择tinymce
官方网站:· PyPI
GitHub:GitHub - jazzband/django-tinymce: TinyMCE integration for Django
1.安装
pip install django-tinymce
2.添加配置
INSTALLED_APPS = ( ... 'tinymce', ...)
3.添加路由配置
urlpatterns = patterns('', ... path('tinymce/', include('tinymce.urls')), ...)
4.为model中表添加字段
from django.db import modelsfrom tinymce.models import HTMLFieldclass MyModel(models.Model): ... content = HTMLField()
5.需要将静态文件导出到项目目录下
python manage.py collectstatic
将会把静态文件导出到STATIC_URL指定的目录下
6.可以对编辑器进行配置私有化定制
TINYMCE_DEFAULT_CONFIG = {
'theme': 'silver', 'width': 1000, 'height': 400, 'language': 'zh_CN', "menubar": "file edit view insert format tools table help", "plugins": "advlist autolink lists link image charmap print preview anchor searchreplace visualblocks code fullscreen insertdatetime media table paste code help wordcount spellchecker","toolbar": "undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist checklist | forecolor backcolor casechange permanentpen formatpainter removeformat | pagebreak | charmap emoticons | fullscreen preview save print | insertfile image media pageembed template link anchor codesample | a11ycheck ltr rtl | showcomments addcomment code",
}
效果:
https://tiny.cloud/docs/
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~