Django 使用UEditor
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的更多相关文章
- django配置Ueditor富文本编辑器
1.https://github.com/twz915/DjangoUeditor3下载包,进入包文件夹,找到DjangoUeditor包拷贝到项目下,和xadmin同级目录 2.找到项目的setti ...
- django配置Ueditor
1.安装DjangoUeditor pip install DjangoUeditor 2.在Django中安装DjangoUedito app,在INSTALL_APPS里面增加DjangoUedi ...
- Django集合Ueditor
语言版本环境:python3.6 1.win安装步骤: git下载源码https://github.com/zhangfisher/DjangoUeditor 解压DjangoUeditor3-mas ...
- Django和Ueditor自定义存储上传文件的文件名
django台后默认上传文件名 在不使用分布式文件存储系统等第三方文件存储时,django使用默认的后台ImageField和FileField上传文件名默认使用原文件名,当出现同名时会在后面追加下随 ...
- python3 Django集成Ueditor富文本编辑器
1.下载 python3: https://github.com/twz915/DjangoUeditor3/ (直接下载zip) 2.解压,解压打开后找到DjangoUeditor将DjangoUe ...
- Django集成百度富文本编辑器uEditor
UEditor是由百度web前端研发部开发所见即所得富文本web编辑器,具有轻量,可定制,注重用户体验等特点,开源基于MIT协议,允许自由使用和修改代码. 首先从ueEditor官网下载最新版本的包, ...
- 学习随笔:Django 补充及常见Web攻击 和 ueditor
判断用户是否登录 <!-- xxx.html --> {% if request.user.is_authenticated %} django中的request对象详解 填错表格返回上次 ...
- Django xadmin后台添加富文本编辑器UEditor的用法
效果图: 步骤: 1.利用命令:pip install DjangoUeditor,安装DjangoUeditor,但由于DjangoUeditor没有python3版本的,从的Github上把修改好 ...
- django—xadmin中集成富文本编辑器ueditor
一.安装 pip命令安装,由于ueditor为百度开发的一款富文本编辑框,现已停止维护,如果解释器为python2,则直接pip install djangoueditor 解压包安装,python3 ...
随机推荐
- 【BZOJ 2462】矩阵模板 (二维哈希)
题目 给定一个M行N列的01矩阵,以及Q个A行B列的01矩阵,你需要求出这Q个矩阵哪些在 原矩阵中出现过. 所谓01矩阵,就是矩阵中所有元素不是0就是1. 输入 输入文件的第一行为M.N.A.B,参见 ...
- 【MySQL】性能优化之 Index Condition Pushdown
一 概念介绍 Index Condition Pushdown (ICP)是MySQL 5.6 版本中的新特性,是一种在存储引擎层使用索引过滤数据的一种优化方式.a 当关闭ICP时,index ...
- 大数据学习——mapreduce程序单词统计
项目结构 pom.xml文件 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=&q ...
- CLR Via CSharp读书笔记(26) - 计算限制的异步操作
执行上下文: 执行上下文包括安全设置(压缩栈.Thread的Principal属性和Windows身份),宿主设置(System.Threading.HostExecutionContextManag ...
- Codeforces Round #321 (Div. 2)-A. Kefa and First Steps,暴力水过~~
A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- bzoj 1503[NOI 2004] 郁闷的出纳员
题目大意: 给4种操作 I:添加一个员工工资信息 A:增加所有员工的工资 S:减少所有员工的工资 F:询问工资第k高的员工的工资情况 自己做的第一道splay树的题目,初学找找感觉 #include ...
- POJ 1080 Human Gene Functions 【dp】
题目大意:每次给出两个碱基序列(包含ATGC的两个字符串),其中每一个碱基与另一串中碱基如果配对或者与空串对应会有一个分数(可能为负),找出一种方式使得两个序列配对的分数最大 思路:字符串动态规划的经 ...
- C语言一些常见的操作字符串方法
// 首字母大写 ;(c=string[i])!='\0';i++) // 字符串碰到\0结束 C知识 { if (c==' ') { printf("%c",c), word=; ...
- linux下部署一个JavaEE项目的简单步骤
部署项目的前提是准备好环境,包括:Java运行环境(JDK),Tomcat,Mysql数据库 1.首先将东西上传到服务器,我是在windows安装ssh工具(下载安装git即可http://gitfo ...
- vs2010 静态使用 opencv 2.46 库
下载opencv2.46的库,假设解压到OpenCV246,设置如下: 在工程的c++的include目录下添加:OpenCV246\opencv\build\include 在工程的c++的lib目 ...