django集成DjangoUeditor
来源:互联网 发布:windows光盘映像刻录机 编辑:程序博客网 时间:2024/05/22 03:42
Django+DjangoUeditor
安装DjangoUeditor
1: Ueditor是百度开发的富文本编辑器,拥有支持的多个版本,但是官方的没有支持Django框架的,在支持的插件里面有一位大牛开发的基于Django的DjangoUeditor,将该App下载,ueditor官网:http://ueditor.baidu.com/website/
2:类似于django其他的插件的安装,将DjangoUeditor的文件夹复制到当前App的同级目录
3:在setting里面注册DjangoUeditor
4:目前我找到的例子都是以form为例讲解的,不清楚直接调用model如何处理,对于form有对应的两种模式:
在DjangoUeditor的github的说明如下:
class TestUeditorModelForm(forms.ModelForm): class Meta: model=Blog***********************************如果不是用ModelForm,可以有两种方法使用:1: 使用forms.UEditorFieldfrom DjangoUeditor.forms import UEditorFieldclass TestUEditorForm(forms.Form): Description=UEditorField("描述",initial="abc",width=600,height=800)2: widgets.UEditorWidgetfrom DjangoUeditor.widgets import UEditorWidgetclass TestUEditorForm(forms.Form): Content=forms.CharField(label="内容",widget=UEditorWidget(width=800,height=500, imagePath='aa', filePath='bb',toolbars={}))widgets.UEditorWidget和forms.UEditorField的输入参数与上述models.UEditorField一样。说明 关于第一种方法,需要在代码中建立相应的类(比如就在views.py中),并且需要在views.py渲染视图的时候返回到模板(template)中,对于上面的代码,具体使用可能如下(在views.py中):from DjangoUeditor.forms import UEditorField class TestUEditorForm(forms.Form): Description=UEditorField("描述",initial="abc",width=600,height=800)def edit_description_view(request): form = TestUEditorForm() return render(request,'edit-description.htm',{"form": form})而在edit-description.htm这个模板(template)里面,只需要在模板相应位置输出form即可:<div class="edit-area"> {{ form }} </div>
5:配置图片、文件的上传地址,如上所述imagePathFormat
在DjangoUeditor的配置文件中,最后上传的图片在编辑器中显示的路径是调用的MEDIA_URL,即指向的是当前App配置的MEDIA_ROOT文件夹下,将MEDIA_URL和App的URL保持一致,否则上传图片之后,资源管理器可以看到,但是当前编辑器界面是找不到的,表示在这坑了一天
先mark一下,继续update……
0 0
- django集成DjangoUeditor
- Django集成DjangoUeditor的cannot import name patterns解决方法
- DjangoUeditor项目的集成
- 使用DjangoUeditor将Ueditor移植到Django(BAE环境下)
- 使用DjangoUeditor将Ueditor移植到Django(BAE环境下)
- 使用DjangoUeditor将Ueditor移植到Django(BAE环境下)
- Django后台开发笔记①:关于DjangoUeditor与python3存在兼容性问题的解决方案(即解决图片无法上传问题)
- django集成fabric
- django-bootstrap集成
- django-bootstrap集成
- webpack人门 & 集成django
- 在django中集成tightvnc
- django集成已有的数据库
- Django集成的子框架
- Django集成LDAP认证方式
- django集成xadmin的方法
- 【Python】Django集成Github登陆
- 在Django Xadmin中集成Ueditor
- HDU5869 Different GCD Subarray Query(2016亚洲区大连站网络赛)
- 程序员再也不用抢月饼了~
- 《剑指offer》简略总结
- leetcode 84. Largest Rectangle in Histogram
- 深入研究memcache 特性和限制
- django集成DjangoUeditor
- onvif测试工具使用方法
- 正则验证注册登录
- CoffeeScript系列教程(三)—声明
- Vertica的这些事<十三>—— Vertica停止数据库的操作步骤
- 一种基于Qt的可伸缩的全异步C/S架构服务器实现(一) 综述
- [LeetCode] 160. Intersection of Two Linked Lists
- 【华为练习题】大数阶乘
- do .....while(0)的用处