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 ...
随机推荐
- 关于Python中包裹传参和解包裹的理解
1.包裹传参 首先思考一个问题:为什么要有包裹传参?原因包括但不仅限于以下两点:①不确定参数的个数.②希望函数定义的更加松散灵活 包裹传参分两种:包裹位置传参和包裹关键字传参.先看包裹位置传参: 在这 ...
- pwnable.kr blackjack之write up
首先我们按提示找到源代码,看这一段: int betting() //Asks user amount to bet { printf("\n\nEnter Bet: $"); s ...
- 2018 GDCPC 省赛总结
第二次参加省赛了,对比上年连STL都不会的acm入门者来说, 今年是接触acm的第二年. 首先要说的是今年的省赛比上年人数多了很多, 闭幕式200多支队伍坐满了整个礼堂还要站着不少人,所以今年的竞争其 ...
- [MVC][Shopping]Copy Will's Code
数据模型规划(Models) //DisplayNameAttribute 指定属性的显示名称 [DisplayName("商品类别")] //DisplayColumnAttri ...
- zoj 2947 Abbreviation
Abbreviation Time Limit: 2 Seconds Memory Limit: 65536 KB When a Little White meets another Lit ...
- CentOS7中,vnc分辨率设置。
使用geometry参数进行调整 例如,我们需要将分辨率调整到800x600 [root@secdb ~]# vncserver -geometry 800x600 New 'secdb:5 (roo ...
- SPOJ LCS2 多个串的最长公共子串
这里串最多有10个,找所有串的最长公共子串 这里后缀自动机做,以第一个串建立后缀自动机,后面的串一个个去匹配,每次得到当前串在可到达状态上所能得到的最长后缀长度 拿所有串匹配后得到的结果进行计算 #i ...
- [NOIP2003] 提高组 洛谷P1041 传染病控制
题目背景 近来,一种新的传染病肆虐全球.蓬莱国也发现了零星感染者,为防止该病在蓬莱国大范围流行,该国政府决定不惜一切代价控制传染病的蔓延.不幸的是,由于人们尚未完全认识这种传染病,难以准确判别病毒携带 ...
- linux 报错:E: Package 'libmemcached' has no installation candidate
linux 报错:E: Package 'libmemcached' has no installation candidate 网上查资料说是软件安装源没有这个软件,需要添加软件源. 1.备份源列表 ...
- mySQL windows 服务
https://www.jizhuba.com/kejiyouxi/20171001/6006.html