Django package 的一些包不支持upload file, 而且 有几个支持的不是收费的就是要开csrf ,这对于苦逼程序猿来说始终是件恼火的事。所以经过查阅各种资料。看了各种各样的配置doc, 最终搞定了django + Ueditor (开源,含upload file 功能的组件)以下粗略写了些步骤:

1. your html page


<head>
<!--FOR UEDITOR -->
<script type="text/javascript" charset="utf-8">
window.UEDITOR_HOME_URL = window.UEDITOR_HOME_URL||"/Ueditor/ueditor/";
</script> <script type="text/javascript" charset="utf-8" src="/static/Ueditor/ueditor/editor_config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/Ueditor/ueditor/editor_all_min.js"></script>
<link rel="stylesheet" type="text/css" href="/static/Ueditor/ueditor/themes/default/ueditor.css"/>
<!--FOR UEDITOR --> </head>​ <form> <p>
<label>提案内容</label>
<textarea class="text-input textarea" id="proposal_content" name="proposal_content" cols="79" rows="15"></textarea>
</p>
<p>

</form> after form <!-- for ueditor-->
<script type="text/javascript">
var ue=new UE.ui.Editor();
ue.render('proposal_content');
</script>
<!--for ueditor-->

​2.in uedior.views:


#coding:utf-8 from proposal_platform import settings #using your project root settings
from django.core.context_processors import csrf
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template.context import RequestContext
from django.views.decorators.csrf import csrf_exempt
from PIL import Image # help to create uplaoded bitmap
import base64
import os
import time
import urllib2
import uuid
from django.utils.encoding import smart_unicode
​ 3.urlconfig:
(
# for UEditor {{
url(r'^ueditor_imgup$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_ImgUp'),
url(r'^ueditor_fileup$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_FileUp'),
url(r'^ueditor_getRemoteImage$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_getRemoteImage'),
url(r'^ueditor_scrawlUp$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_ScrawUp'),
url(r'^ueditor_getMovie$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_getMovie'),
url(r'^ueditor_imageManager$', 'proposal_platform.UeditorApp.Ueditor.views.ueditor_imageManager'),
# }}

# 这里是否使用/admin/aaa.html的请求 ,假设有静态网页的请求要在里面单独设计 {{
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
url(r'^(?!admin)(? P<path>.*)$','django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
url(r'^(? P<path>.*)$', 'django.views.static.serve', {'document_root': settings.ADMIN_HTML_ROOT}),
# }}
​)
if settings.DEBUG is False:
urlpatterns += patterns('',
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT
}),
)

4.the full dir of the project:

watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbF9mMHJtNHQzZA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />

Django 使用UEditor的更多相关文章

  1. django配置Ueditor富文本编辑器

    1.https://github.com/twz915/DjangoUeditor3下载包,进入包文件夹,找到DjangoUeditor包拷贝到项目下,和xadmin同级目录 2.找到项目的setti ...

  2. django配置Ueditor

    1.安装DjangoUeditor pip install DjangoUeditor 2.在Django中安装DjangoUedito app,在INSTALL_APPS里面增加DjangoUedi ...

  3. Django集合Ueditor

    语言版本环境:python3.6 1.win安装步骤: git下载源码https://github.com/zhangfisher/DjangoUeditor 解压DjangoUeditor3-mas ...

  4. Django和Ueditor自定义存储上传文件的文件名

    django台后默认上传文件名 在不使用分布式文件存储系统等第三方文件存储时,django使用默认的后台ImageField和FileField上传文件名默认使用原文件名,当出现同名时会在后面追加下随 ...

  5. python3 Django集成Ueditor富文本编辑器

    1.下载 python3: https://github.com/twz915/DjangoUeditor3/ (直接下载zip) 2.解压,解压打开后找到DjangoUeditor将DjangoUe ...

  6. Django集成百度富文本编辑器uEditor

    UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码. 首先从ueEditor官网下载最新版本的包, ...

  7. 学习随笔:Django 补充及常见Web攻击 和 ueditor

    判断用户是否登录 <!-- xxx.html --> {% if request.user.is_authenticated %} django中的request对象详解 填错表格返回上次 ...

  8. Django xadmin后台添加富文本编辑器UEditor的用法

    效果图: 步骤: 1.利用命令:pip install DjangoUeditor,安装DjangoUeditor,但由于DjangoUeditor没有python3版本的,从的Github上把修改好 ...

  9. django—xadmin中集成富文本编辑器ueditor

    一.安装 pip命令安装,由于ueditor为百度开发的一款富文本编辑框,现已停止维护,如果解释器为python2,则直接pip install djangoueditor 解压包安装,python3 ...

随机推荐

  1. ajax 为 select 赋值

    html 页面<tr> <td class="dc-form-left">权限组:</td> <td class="dc-for ...

  2. [WPF自定义控件]使用WindowChrome自定义Window Style

    1. 为什么要自定义Window 对稍微有点规模的桌面软件来说自定义的Window几乎是标配了,一来设计师总是克制不住自己想想软件更个性化,为了UI的和谐修改Window也是必要的:二来多一行的空间可 ...

  3. ERP类系统设计学习

    文章:分布式.服务化的ERP系统架构设计 文章的方法是对系统进行拆分,拆分成多个子系统.

  4. 为docker容器设置独立ip

    docker 1.12使用新版macvlan设置与宿主机同网段ip ****************************************** 由于开发的一些特殊需求,需要将容器部署在与宿主 ...

  5. 原生js操作dom的方法

    今天学习了原生js的dom节点的操作,就记录下来,仅供自己以后参考. 1)创建节点:除了可以使用createElement创建元素,也可以使用createTextNode创建文本节点. documen ...

  6. 开头第一篇Hello World

    以前在折腾个人博客的时候,使用过的WordpPress.Z-Blog.Typecho建站程序,开头第一篇都是Hello World,作为程序员的社区,开头第一篇当然也要是Hello World! 一句 ...

  7. foobar2000使用cue文件播放时出现Unable to open item for playback (Object not found):的问题解决

    如下错误: 一般是找不到APE文件导致的.解决方法如下: 1.打开APE文件,对一下路径修改即可.

  8. 碧砚适合佳能328 4452 ICD520 4472 4450 硒鼓4700一体机墨盒4770

  9. Linux信号通讯编程

    信号通讯流程为: ①进程A/内核选择信号 ②发送信号 ③进程B接收信号并处理 Linux系统支持的全部信号均定义在/usr/include/asm/signal.h.当中常见的信号有: ①SIGKIL ...

  10. Jackson说明

    Jackson说明 package com.stono.sboot2_chp4_jackson.controller; import com.fasterxml.jackson.annotation. ...